> If I have an XML Document
> <?xml version="1.0" encoding="UTF-8" ?>
[quoted text clipped - 8 lines]
> I am able to retrieve a given nodex text and attribute values by using JAXEN
> XPath, but how do I edit the nxattr value and nodex text?
I got this working eventually.
try{
XPath expression = new DOMXPath("//root/nodex");
result=(Element) expression.selectSingleNode(xmlDocument);
//This worked from the outset
result.setAttribute("nxattr", "newatrrvalue");
//This didn't work. The output showed the node with an updated attribute
value, but the text unchanged
//result.setNodeValue("My New Data");
//This, however, worked just fine
result.getFirstChild.setNodeValue("My New Data");
System.out.println(result.toString());
}
catch(JaxenException e){e.printStackTrace;}
catch(DOMException e){e.printStackTrace;}
So when selecting a node, it appears that the Nodes text value is a child of
the node, although the attribute is not.
Gerorge