This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EDITING/DELETING part of XML using XMLbeans

 
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.
 
Author and all-around good cowpoke
Posts: 13078
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
Posts: 13078
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic