D
dat
Hi,
I have an XML file like this:
articleSet
article
title
/title
author
/author
/article
article
title
/title
author
/author
/article
/articleSet
using dom4j I put this XML into a org.dom4j.Document (named xmlDoc) and
for each "article" Node I wuold like to do some stuff so I wrote this code
Iterator iter = xmlDoc.selectNodes("//article").iterator();
while(iter.hasNext()){
Node n = (Node)iter.next();
System.out.println(n.asXML());
System.out.println(n.selectSingleNode("//title").getText());
}
the problem is that the first "println" prints correctly the content of
each "article" Node but the second prints always the FIRST article title
because the XPath search is done on entire document and not only inside
the current node.
Why this behaviour? I made some mistakes?
dat
I have an XML file like this:
articleSet
article
title
/title
author
/author
/article
article
title
/title
author
/author
/article
/articleSet
using dom4j I put this XML into a org.dom4j.Document (named xmlDoc) and
for each "article" Node I wuold like to do some stuff so I wrote this code
Iterator iter = xmlDoc.selectNodes("//article").iterator();
while(iter.hasNext()){
Node n = (Node)iter.next();
System.out.println(n.asXML());
System.out.println(n.selectSingleNode("//title").getText());
}
the problem is that the first "println" prints correctly the content of
each "article" Node but the second prints always the FIRST article title
because the XPath search is done on entire document and not only inside
the current node.
Why this behaviour? I made some mistakes?
dat