Thanks.
But now the problem is, how do I get a reference to the parent? I thought I was 
getting a reference with selectPath() but apparently not. The XML file is HUGE 
with tons of elements, data, etc. There is only one instance of WIPKEYS so I 
would just like to replace what's there.
If I get a reference to WIPKEYS and call what you have below;
wipkeys[0].set(keys.getWIPKEYS()); it will just replace that copy and not the 
WIPKEYS section in the root of the main XML doc (XMLINI).
Thanks,
bob


----- Original Message ----
From: Cezar Andrei <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, August 15, 2007 3:40:33 PM
Subject: RE: 2nd Post. Help! Search and Replace...Re: How to edit data in a 
specific part of an XMLObject


Bob, 
 
The wipkeys array returned from selectPath() method is just a copy, it’s not a 
live object in XMLBeans structures, so modifying it will not change the 
original document.
 
You should call wipkeys[0].set(keys.getWIPKEYS()); or locate it’s parent and 
call parent.setWIPKEYS(keys.getWIPKEYS()) .
 
Cezar
 



From: bob bob [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 15, 2007 1:25 PM
To: [email protected]
Subject: 2nd Post. Help! Search and Replace...Re: How to edit data in a 
specific part of an XMLObject
 
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. 
 
 



Shape Yahoo! in your own image. Join our Network Research Panel today! 

Notice: This email message, together with any attachments, may contain 
information of BEA Systems, Inc., its subsidiaries and affiliated entities, 
that may be confidential, proprietary, copyrighted and/or legally privileged, 
and is intended solely for the use of the individual or entity named in this 
message. If you are not the intended recipient, and have received this message 
in error, please immediately return this by email and then delete it.


       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

Reply via email to