python - firefox dom/xpath question/issue

Diez B. Roggisch deets at nospam.web.de
Mon Aug 25 18:44:39 EDT 2008


bruce schrieb:
> Hi.
> 
> Got a test web page, that basically has two "<html" tags in it. Examining
> the page via Firefox/Dom Inspector, I can create a test xpath query
> "/html/body/form" which gets the target form for the test.
> 
> The issue comes when I examine the page's source html. It looks like:
> <html>
> <body>
> </body>
> </html>
> 
> <html>
> <body>
> .
> .
> .
> </body>
> </html>
> 
> I've simplified things a bit... but basically, the 1st "html/body" is empty,
> with the 2nd containing the data/nodes I need.

If that's your document, it is invalid XML - XML only allows *one* root. 
Thus the parsers failure isn't too suprising.

Try & wrap the whole document under an arbitrary root-tag, and included 
that as first part of the xpath. See if that helps.

Diez



More information about the Python-list mailing list