tags:

views:

18

answers:

2
Node existingUserNode = loginDoc.selectSingleNode("/returningUser");
String username = existingUserNode.selectSingleNode("/username").getText();
String password = existingUserNode.selectSingleNode("/password").getText();

for

<?xml version="1.0" encoding="UTF-8"?><returningUser><username>user</username><password>password</password></returningUser>

returns null.

I don't think my xpath is wrong? Or am I using the wrong method?

A: 

The syntax should be ./username and ./password... above I am looking one level too high by referencing the root

A: 

try this

Node existingUserNode = loginDoc.selectSingleNode("/returningUser");
String username = existingUserNode.selectSingleNode("/username").getNodeValue();
String password = existingUserNode.selectSingleNode("/password").getNodeValue();