Click here to Skip to main content
15,888,220 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
This is our CMIS(Computer Management Information System) Server page: (Note: The CMIS server I cannot modify, the page is automatic generation.)

HTML
<form method="POST" action="bl_view_invoice_controler.jsp" name="fm1"  önSubmit="return checkValid()"> //please attention the form name is 'fm1'
      <TABLE id=AutoNumber7 style="BORDER-COLLAPSE: collapse" 
                      borderColor=#111111 cellSpacing=0 cellPadding=2 width="100%" 
                      border=0>
                        <TBODY>
                        <TR>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                        </TR>
    <TR>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                          <TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
                          <TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
                        </TR>
                          </TBODY></TABLE>
    <script language="JavaScript"> //this script store the value of the table
                    fm1.ivcd_item['0'].value="B747-400";
                    fm1.ivcd_totalfc['0'].value="500.00";
                    fm1.ivcd_unitprice['0'].value="1";
                    fm1.ivcd_quantity['0'].value="";

                    fm1.ivcd_item['2'].value="B747-800";
                    fm1.ivcd_totalfc['2'].value="250.00";
                    fm1.ivcd_unitprice['2'].value="";
                    fm1.ivcd_quantity['2'].value="";
     </script>          
    </FORM>


My question is, How to use C# get the value of the table, suach as 'B747-400' or 'B747-800'? My idea is use BHO(Browse Helper Object), but How to do?
Posted

This is not going to be easy. It is easy enough to parse the XML parsing the XML into a XDocument:

string str =
@"
<!-- comment at the root level -->
<root>
    <child>Content</child>
</root>";
XDocument doc = XDocument.Parse(str);


This will allow you to get to all the information in the xml, including the content of the script tag by using the following

C#
child = doc.Descendants("Child").FirstOrDefault();
Console.WriteLine(child.Value);


Unfortunately, still have to parse the content of the script tag. That will require you to go through and do the hard work. What I recommend is to use regular expressons. I am not an expert at working with regular experssions, and it is going to require some fancy stuff to do the extraction, but I have seen some really neat stuff with regular expressons, for instance C# Formula Evaluator using Regular Expressions (http://www.jarloo.com/c-formula-evaluator[^]). You will have to read up on regular expressons.
 
Share this answer
 
v2
You can easily parse html using tools like the HtmlAgilityPack[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900