To get the parent you can use the cursor API or write a more specific xpath 
something like /a/b/c/.. .

 

Cezar

 

________________________________

From: bob bob [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 15, 2007 4:10 PM
To: [email protected]
Subject: Re: 2nd Post. Help! Search and Replace...Re: How to edit data in a 
specific part of an XMLObject

 

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. 
<http://us.rd.yahoo.com/evt=48224/*http:/sims.yahoo.com/> 

 

 

________________________________

Shape Yahoo! in your own image. Join our Network Research Panel today! 
<http://us.rd.yahoo.com/evt=48517/*http:/surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7>
  


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.

 

 

________________________________

Ready for the edge of your seat? Check out tonight's top picks 
<http://us.rd.yahoo.com/evt=48220/*http:/tv.yahoo.com/>  on Yahoo! TV. 


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.

Reply via email to