File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes EDITING/DELETING part of XML using XMLbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "EDITING/DELETING part of XML using XMLbeans" Watch "EDITING/DELETING part of XML using XMLbeans" New topic
Author

EDITING/DELETING part of XML using XMLbeans

Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Hi Ranchers,
I am using XMLbeans for reading and writing an XML. I am able to ADD and READ only.
. I am not able to find resources for EDITING/DELETING the exiting XML data.
For Example: If i have a XML like below:

<?xml version="1.0" encoding="UTF-8"?>
<query xsi:noNamespaceSchemaLocation="query.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<question>
<qid>Q2097408831</qid>
<qtext>What do you mean by JVM ?</qtext>
<qcode/>
<qcat>1</qcat>
<qtype>S</qtype>
<qcreationdate>2009-02-19+05:30</qcreationdate>
<qcreationtime>09:34:36.750+05:30</qcreationtime>
<answerexpl>Visit www.java.com</answerexpl>
<answeroptions>
<answer>
<aid>A445346947</aid>
<atext>Jakarta Virtual Machine</atext>
<iscorrect>false</iscorrect>
</answer>
<answer>
<aid>A1659018288</aid>
<atext>Java Visual Machine</atext>
<iscorrect>false</iscorrect>
</answer>
<answer>
<aid>A872265915</aid>
<atext>Java Virtual Machine</atext>
<iscorrect>true</iscorrect>
</answer>
<answer>
<aid>A1509971747</aid>
<atext>Java Runtime Virtual Machine</atext>
<iscorrect>false</iscorrect>
</answer>
<answer>
<aid>A1861322354</aid>
<atext>Java Tiger Pack</atext>
<iscorrect>false</iscorrect>
</answer>
</answeroptions>
</question>
<question>...</question>
<question>...</question>
<question>...</question>
<question>...</question>
</query>

How to EDITING/DELETING the existing question object.

Thanks

SCJP, SCWCD, SCMAD, SCEA, OCPJP 7, CSM
Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Any Idea about this...


Kindly help.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Why cant you just modify the bean object and/or delete beans from the collection that represents the XML??



Bill
Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Hi William,
I want to edit new <question> tag with data in XML. if I would do that in collection that will not be effeted in XML.

So I need to change some part of question and save that change
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
So I need to change some part of question and save that change


IF you are committed to the XMLbeans approach then ALL changes, additions or deletions MUST be represented as a changed, added or deleted bean.

You have not described how your data is mapped to beans - logically there would be one bean per question and the collection of beans would be held in a Java collection such as ArrayList or similar. If this is not the case, what is your mapping of data to beans?

Bill
Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Thanks for the right direction William . I got it and implemented the way you said. Life is cool now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EDITING/DELETING part of XML using XMLbeans