You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Kakoli <ka...@india.hp.com> on 2002/04/15 15:38:31 UTC
Query on using XPath.
Hi,
I am trying to use XPath feature of Xalan-Java 2.3.1
My xml file looks thus :
<config>
<params>
<configDir>xxx</configDir>
<serverDir>yyy</serverDir>
</params>
<operator-list>
<operator name="Opr 1">
<preferred-language>en</preferred-language>
<database>MSSQL</database>
</operator>
<operator name="Opr 2">
<preferred-language>fr</preferred-language>
<database>Oracle</database>
</operator>
</operator-list>
</config>
I first parsed the entire document and then used
XPathAPI.selectNodeIterator(Document, xpath) method to get values like xxx
by using xpath : /config/params/configDir/text()
Then I have extracted the node operator from the file. Now I need to extract
<database> values from that by giving the path relative to the operator
node. I am giving this part
of code below:
NodeList nl = null;
nl = doc.getOprNodesFromDoc();
int size = nl.getLength();
System.out.println("Size " +size);------------------> number of
<operator> nodes.
for(int i = 0; i < size; ++i) {
Node opr = nl.item(i);
str = XPathAPI.selectNodeIterator(opr,
xpath);--------------------> What should be the xpath here if it is relative
to the operator node.
}
Using xpath operator/database/text() is not working. And I do not want to
use the full path starting from /config.
Any solutions?
Thanks and Regards,
Kakoli