commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurizio Cucchiara <mcucchi...@apache.org>
Subject Re: [jxpath] querying an html file
Date Tue, 12 Mar 2013 15:23:15 GMT
Hi Stefano,
usually xpath suits better for xml compliant document.
Although I don't know how jxpath can address your requirements, I'd
consider, for html documents, jsoup (http://jsoup.org/) as a better
choice for your use case.


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara

Maurizio Cucchiara


On 12 March 2013 12:49, MASTRELLA STEFANO <smastrella@sogei.it> wrote:
>
>
> Hi all,
>
> I'm trying to use jxpath-1.3 to query the content of some tags within an
> html fragment.
> Given the file 'html.frag.response.html' I want to explore all the TR
> tag in the document.
>
> For what I know I can do this stuff with the following lines of code:
>
>   String tableFragment = loadfromthefile();
>
>   JXPathContext context = JXPathContext.newContext(tableFragment);
>
>   Iterator it = context.iteratePointers("//TR");
>
>   while (it.hasNext()) {
>      Pointer msgPointer = (Pointer) it.next();
>
>      msgPointer.asPath();
>
>      System.out.println(msgPointer);
>
> What I get is always an empty Iterator so there's nothing to iterate on,
> as there were no TR tag
> in the document.
>
> What am I doing wrong?
>
> TIA.
>
> ---
> Stefano
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message