asp classic - ASP extracting table on HTML -


i have html structure saved on asp variable called strresponse1

all want extract specific table on it. table has constant class named "datatableparent". had made simple code extract table using ubound , lbound vbscript function

here simple code:   dim str, tmp, toptmp, bottmp, tablestr str = strresponse1 tmp = split(str, "datatableparent")             toptmp = tmp(ubound(tmp))             tmp2 = split(toptmp, "</table>")             bottmp = tmp2(lbound(tmp2))             tablestr = "<table class=" & chr(34) & "datatableparent" & bottmp & "</table>" 

so used asp trim function, ubound trimming upper bound string, , lbound trimming lower bound string. used table class: datatableparent starting point upper bound trimming , </table> ending point lower bound trimiming. code working on extracting table problem is, there table on parent "<td>" struggling me extract the table correctly.

check html sample table structure

<html> <head> <title></title> </head> <body>    <table class="datatableparent">        <tr>              <td>                    <table>                         <tr>                               <td>this example of table elements</td>                         </tr>                    </table>              </td>        </tr>     </table> </body> </html> 

since code identifies first closing table tag, trimming stops when found first closing tag </table>, knowing there 2 closing tag table here. how can possibly extract table on correct ending tag? help? in advance. :)

as always: don't use string processing on html.

option explicit  dim doc, table set doc = createobject("htmlfile")  ' ... set strresponse1 ...  doc.write strresponse1  each table in doc.body.getelementsbytagname("table")     if table.classname = "datatableparent"         ' use dom methods navigate correct table cell , extract data          ' of, e.g., innertext()     end if next 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -