I have and XMLObject node I find by using an XPath expression in my XMLObject
root element (XMLINIDocument). It finds this XMLObject (there is only one
instance) but I want to replace it with another one. How do I do this?
** XML DOCUMENT **
<XMLINI>
<CONFIG>
<SERVICES>
<SERVICE>
<WIPKEYS>
I WANT TO REPLACE THIS DATA
</WIPKEYS>
.....
</XMLINI>
** CODE **
// Load entire XML document
XMLINIDocument config = XMLINIDocument.Factory.parse(editor.getText(),
validateOptions);
// Create xpath to the node we wish to replace
String wipQueryExpression = "declare namespace
xq='http://skywire.com/ccm/global';" +
"$this/xq:XMLINI/xq:CONFIG/xq:SERVICES/xq:SERVICE/xq:WIPKEYS";
// XMLObject found through XPath. This is the one I want to replace with the
new one.
WIPKEYSDocument.WIPKEYS[] wipkeys = (WIPKEYSDocument.WIPKEYS[])
config.selectPath(wipQueryExpression);
// Got XML data from server and loaded it into a WIPKEYSDocument and wish to
replace the wipkeys above with this one
WIPKEYSDocument keys = WIPKEYSDocument.Factory.parse(serverData,
validateOptions);
// This kind of substitution does not work
wipkeys[0] = keys.getWIPKEYS();
// Then I save it at the end
config.save(new File("war/WEB-INF/xml/global.xml"));
Any ideas?
Thx,
Bob
____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the
Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/