function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SudhanwaSudhanwa 

HTML file parsing

 Hi,

 

I have this really complex requirement here.

Users upload a HTML file into Salesforce. The HTML file contains a table with two columns the first column being the field and the second being its value. There are some fields in the table (in random order in the table in different files) who are under consideration. What I need to do is, I should parse the HTML file, look for the <td>s which have the fields I require, move to the immidiate next <td> and store those value in a map against their field names.

 

Can you guys give me some idea on how to go about it?

 

p.s. I dont even know how to begin!

 

Thanks,

Sudhanwa.

wesnoltewesnolte

Hey

 

You could try using or adapting the standard XMLDom apex class to parse the HTML file, that's all HTML (or should I say well formed HTML) is anyway. You'll find the class in your list of apex classes unless you've deleted it.

 

Your idea of parsing the file and looking for the <td>s should suffice as long as the document is well formed.

 

Cheers,

Wes 

SudhanwaSudhanwa

<tr>
    <td colspan="1">
    <font size="+1">
        <center>
            Sudhanwa
        </center>                    
    </font>
</td>
    <td colspan="1">
    <font size="+1">
        <center>
            Sardeshpande
        </center>                    
    </font>
</td>
</tr>

 

In the above piece of HTML, I would want to parse and capture the values "Sudhanwa" and "Sardeshpande" on to a map (key being "Sudhanwa" and value being "Sardeshpande"). Any technique you 're aware of?

 

Thanks,

Sudhanwa.