Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   XPath to analyze HTML table (http://www.velocityreviews.com/forums/t165268-xpath-to-analyze-html-table.html)

Achim Domma 07-29-2003 09:41 PM

XPath to analyze HTML table
 
Hi,

I have some HTML code, converted to XML and want to get the content of
special table cells. The XML looks like this:

....
<tr>
<td width="200">
<font class="content">Project ID</font>
</td>
<td width="200">
<font class="content">12345</font>
</td>
</tr>
....

I want to get '12345' and tried it with an XPath expression like this:

'//font[starts-with(text(),"Project")]/parent/parent/td[2]/font/text()

It does not work, but I don't understand why!? Can anybody help?

regards,
Achim



Dimitre Novatchev 07-30-2003 06:40 AM

Re: XPath to analyze HTML table
 

"Achim Domma" <domma@procoders.net> wrote in message
news:bg6pn2$c9l$02$1@news.t-online.com...
> Hi,
>
> I have some HTML code, converted to XML and want to get the content of
> special table cells. The XML looks like this:
>
> ...
> <tr>
> <td width="200">
> <font class="content">Project ID</font>
> </td>
> <td width="200">
> <font class="content">12345</font>
> </td>
> </tr>
> ...
>
> I want to get '12345' and tried it with an XPath expression like this:
>
> '//font[starts-with(text(),"Project")]/parent/parent/td[2]/font/text()
>
> It does not work, but I don't understand why!? Can anybody help?



The reason is that there are no "parent" elements defined in html.

Probably you meant parent::* or simply ".."


I would re-write your XPath expression to something like the following:

//tr[td/font[starts-with(., 'Project')]]/td[2]/font/text()[1]


Another recommendation is to download the XPath Visualizer and play with it
to learn XPath the fun way.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




All times are GMT. The time now is 08:12 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.