HTMLDocument and Xpath

swilson at acs.on.ca swilson at acs.on.ca
Fri Feb 3 09:21:14 EST 2006


Alan Kennedy wrote:
> [swilson at acs.on.ca]
> > Hi, I want to use xpath to scrape info from a website using pyXML but I
> > keep getting no results.
> >
> > For example, in the following, I want to return the text "Element1" I
> > can't get xpath to return anything at all.  What's wrong with this
> > code?
>
> Your xpath expression is wrong.
>
> > test = Evaluate('td', doc_node.documentElement)
>
> Try one of the following alternatives, all of which should work.
>
> test = Evaluate('//td', doc_node.documentElement)
> test = Evaluate('/html/body/table/tr/td', doc_node.documentElement)
> test = Evaluate('/html/body/table/tr/td[1]', doc_node.documentElement)
>
> HTH,
>
> Alan.

I tried all of those and in every case, test returns "[]".  Does
Evaluate only work with XML documents?

Shawn




More information about the Python-list mailing list