You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Joerg Lensing <in...@softcon-lensing.de> on 2003/04/11 20:18:58 UTC

[jxpath] newbie: iterator doesn't return sinlge object

hi list,
I'm using xpath-String :
         String xpathString = "/*";

and

>           JXPathContext context = JXPathContext.newContext(recipes);
>           System.out.println("Activated the XMLSource");
>
>           Iterator resultSet = context.iterate(xpathString);
>           //String result = (String) context.getValue(xpathString);
>
>           while (resultSet.hasNext()) {
>               Object aObj = (Object) resultSet.next();
>             String result = (String) aObj;
>             System.out.println("The result is: " + result);
>           }     

The first retrieved object from resultSet.next() contains the complete
values from all nodes. That is not what i expected.
My questions:
1. How can i iterate through the nodes?
2. How can i get the node-name (like the name()-function in xpath)?


joerg


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


Re: [jxpath] newbie: iterator doesn't return sinlge object

Posted by Dmitri Plotnikov <dp...@yahoo.com>.
Jeorg,

1. Use iteratePointers instead of iterate.
2. The name() function works fine with JXPath.

- Dmitri

--- Joerg Lensing <in...@softcon-lensing.de> wrote:
> hi list,
> I'm using xpath-String :
>          String xpathString = "/*";
> 
> and
> 
> >           JXPathContext context =
> JXPathContext.newContext(recipes);
> >           System.out.println("Activated the XMLSource");
> >
> >           Iterator resultSet = context.iterate(xpathString);
> >           //String result = (String) context.getValue(xpathString);
> >
> >           while (resultSet.hasNext()) {
> >               Object aObj = (Object) resultSet.next();
> >             String result = (String) aObj;
> >             System.out.println("The result is: " + result);
> >           }     
> 
> The first retrieved object from resultSet.next() contains the
> complete
> values from all nodes. That is not what i expected.
> My questions:
> 1. How can i iterate through the nodes?
> 2. How can i get the node-name (like the name()-function in xpath)?
> 
> 
> joerg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

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