How to get value of specific child node
I am trying to access the password of a specific user like jsmith in the following xml:
<xml>
<Users>
<User>
<Name>jsmith</Name>
<Password>xyz</Password>
</User>
<User>
<Name>kmiller</Name>
<Password>abc</Password>
</Users>
<xml>
Code:
Element node = (Element) XPathAPI.selectSingleNode(document, "/Users/User[Username=\"" + username + "\"]");
if (node != null) {
Element pswdNode = (Element)XPathAPI.selectSingleNode(node, "Password");
String value = pwdNode.getFirstChild().getNodeValue();
}
The code above gives me a value of null. What am I doing wrong?
Thanks!