Hi Jesse,
Using
//operator/database/text() gives me the last value Oracle only, though it
iterates through all values.
The values are available by giving the abolute path where context-node is the entire document
like:
/config/operator-list/operator[1]/database/text()
-------------> MSSQL
/config/operator-list/operator[2]/database/text()
-------------> Oracle
But I do not want to use the index. Instead I want to give relative path where the context node is the individual <operator> node. And I want to run it in a for loop. In that case, what should be the XPath?
Xpath operator/database/text() on the first <operator> node as context should return MSSQL.
Xpath operator/database/text() on the second <operator> node as context should return Oracle. But it is giving null.
Thanks & Regards,
Kakoli
-----Original Message-----
From: Jesse
Hersch [mailto:[EMAIL PROTECTED]]
Sent:
Monday, April 15, 2002 8:16 PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Re: Problem with Xpath
try
//operator/database/text()
this will match all text nodes under
operator/database, no matter where that
structure exists in the
doc.
-jesse
----- Original Message -----
From:
Kakoli
To: [EMAIL PROTECTED]
Sent: Monday, April 15, 2002 7:01
AM
Subject: Problem with 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 help would be appreciated.
Thanks and
Regards,
Kakoli
