Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EDITING/DELETING part of XML using XMLbeans

 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Idea about this...


Kindly help.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cant you just modify the bean object and/or delete beans from the collection that represents the XML??



Bill
 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the right direction William . I got it and implemented the way you said. Life is cool now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic