Hi,
I have just started using dom4j to parse the xml.
I am having problem using selectNodes and SelectSingleNode.
I have a simple xml as follows:
<SchedRemote xmlns="http://scheduall.com/webservices/">
<Response>
<Error>Login failed, Error: Invalid login information.</Error>
</Response>
</SchedRemote>
What I want to do is check to see if I received any ERRORS. This means that
i
f ERROR tag is found inthe XML.
If ERROR tag is found then I would also like to read the ERROR txt.
But for some resons it is not working:
Here is what I have done last:
Document doc = DocumentHelper.parseText(any[i].toString());
-------> List list = doc.selectNodes("//SchedRemote");
//List list = doc.selectNodes("//Response");
System.out.println("List size =>" + list.size());
if (list.size() > 0)
{
System.out.println("ERROR Found");
-----> Node node = doc.selectSingleNode( "/Error" );
if (node != null)
{
System.out.println("asXML =>" + node.asXML());
String path = node.getPath();
XPath xPath = node.createXPath(path);
if (xPath.selectSingleNode("//Error") != null)
{
System.out.println("Error node found");
}
}
}
Output =>
List size =>1
List[0] = =>[EMAIL PROTECTED] [Element: <SchedRemote
uri:http://scheduall.com/webservices/ attributes: []/>]
ERROR Found
I cannot seem to get the node ERROR, when I set doc.selectSingleNode
("/Error") OR
when I set the doc.selectNodes to be (//Response) or (//Error) or
(//SchedRemote/Error).
What am I doing wrong? and any help would be appreciated.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user