Anyone?
Basically I want a search and replace. I can grab the XMLObject 
(WIPKEYSDocument) but can't replace it with another 
WIPKEYSDocument.
Please?! Anyone?


----- Original Message ----
From: bob bob <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, August 14, 2007 3:52:32 PM
Subject: How to edit data in a specific part of an XMLObject


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



Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.


       
____________________________________________________________________________________Ready
 for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

Reply via email to