My guess is that Matt meant a runnable test (like JUnit).

Also did you notice that the first tag *TR* tag is lower case, and the
others are uppercase?
That could make the difference.


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 14 March 2013 10:34, MASTRELLA STEFANO <[email protected]> wrote:

> Hi Matt,
>
> I wrote a simple test case to explain what I'm looking for, I'd like to
> reach and get the 4th TD html tag
> within the second TR tag in the TABLE html element, that is the string
> 'Good'.
>
> What I get is the following stacktrace
>
>   org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath:
> /TABLE/TR[2]/TD[4]
>     at
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathC
> ontextReferenceImpl.java:383)
>     at
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathC
> ontextReferenceImpl.java:313)
>     at test.HtmlQueryingTestCase.test(HtmlQueryingTestCase.java:35)
>
> TIA,
>
> Stefano.
>
> > -----Original Message-----
> > From: Matt Benson [mailto:[email protected]]
> > Sent: Tuesday, March 12, 2013 3:27 PM
> > To: Commons Users List
> > Subject: Re: [jxpath] querying an html file
> >
> > Can you put together a small test case that illustrates the problem?
> >
> > Matt
> >
> >
> > On Tue, Mar 12, 2013 at 6:49 AM, MASTRELLA STEFANO
> > <[email protected]>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: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

Reply via email to