Hallo Christoph,

Christoph Vollmer wrote:

> Hi,
> 
>  
> 
> I've got a problem with selectSingleNode. I have a XML-Document like
>
> I put the two nodes <Benutzer_rec> in a new list and use the following 
> code to select the childnodes:
> 
>         for ( Iterator iter = newContacts.iterator(); iter.hasNext(); ) {
>             Element element = (Element) iter.next();
>             System.out.println("Komplett: " + element.asXML());
>             System.out.println("Name: " + 
> element.selectSingleNode("//Nachname").getText());
>         }
> I can iterate over the elements, of course no problem. "element.asXML()" 
> shows me the right element. But 
> "selectSingleNode("//Nachname").getText())" always gives me the same 
> value "Negativer"! Is this a bug or am I doing something wrong?



selectSingleNode("//Nachname") always gives you the first 'Nachname' Node in 
your document since your XPath-expression starts at the document root ("//") 
and selectSingleNode() returns the first Node matching;

selectSingleNode(".//Nachname") should work.


Markus




_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to