You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Mark A. Richman" <mr...@ispchannel.com> on 2000/11/04 14:19:31 UTC
XPath problem
I am using Xalan-J 1.2 (10/13/2000) to evaluate the following expression on this XML file:
<?xml version="1.0"?>
<users>
<user username="mark" password="mypassword" email="mark@markrichman.com"
rootfolder="c:/users/mark/"/>
<user username="mark2" password="mypassword2" email="mark2@markrichman.com"
rootfolder="c:/users/mark2/"/>
<user username="mark3" password="mypassword3" email="mark3@markrichman.com"
rootfolder="c:/users/mark3/"/>
<user username="mark4" password="mypassword4" email="mark4@markrichman.com"
rootfolder="c:/users/mark4/"/>
</users>
When I apply the following XPath expression, I retrieve a Node:
//users/user[@username='mark']
But when I substitute @username='mark2', I get a null Node object back.
What gives? Here is my code:
try
{
parser.parse(xmlFile);
}
catch (Exception e)
{
e.printStackTrace();
}
document = parser.getDocument();
Node root = parser.getDocument().getDocumentElement();
Node usernode = null;
//XPath looks like: "/users/user[@username='mark']"
String xpath = "//users/user[@username='" + username +"']";
System.out.println("XPath: " + xpath);
try
{
usernode = XPathAPI.selectSingleNode(root, xpath); // getting null usernode with 'mark2' here!!!!
}
catch(Exception ex)
{
System.out.println(ex);
}
Thanks,
Mark
Re: XPath problem
Posted by Gary L Peskin <ga...@firstech.com>.
> "Mark A. Richman" wrote:
> What gives? Here is my code:
Mark ---
Did you ever get this resolved?
Gary