Results 1 to 2 of 2
- 07-11-2009, 05:19 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
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>
The code above gives me a value of null. What am I doing wrong?Java 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(); }
Thanks!
- 07-13-2009, 12:00 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
how to get the child class in inheritance?
By java_fun2007 in forum New To JavaReplies: 7Last Post: 09-29-2010, 09:35 AM -
Cannot add or update a child row....
By Pierced1 in forum JDBCReplies: 2Last Post: 06-29-2009, 02:32 AM -
Child Labor
By freddieMaize in forum Forum LobbyReplies: 1Last Post: 11-16-2008, 08:59 PM -
how do i print a specific txt file on a specific printer
By nikhilbhat in forum New To JavaReplies: 2Last Post: 11-08-2008, 10:40 AM -
Parent & Child window issues......
By jithan in forum New To JavaReplies: 2Last Post: 09-20-2008, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks