Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
XML and Related Technologies
Add elements to already created XML
ram gaurav
Ranch Hand
Posts: 208
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I am new to XML.
Right now i am able to read or parse XML with help of my
java
code.
I have my XML file as follows:
<RootElement> <InnerParent> <text>abc</text> <text>xyz</text> </InnerParent> <RootElement>
Now i want to update this xml with help of my java code, like with help of my java code i can add more <text></text> element into xml.
Thanks
Gaurav
Jesus Angeles
Ranch Hand
Posts: 2108
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
For reading/parsing the xml, you probably used an implementation of SAX.
SAX cant update the xml that you have loaded into memory using java.
You can use DOM to both read/parse xml, update it, then write it out to an output destination like a file.
ram gaurav
Ranch Hand
Posts: 208
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks for your reply.
Sir can you please give me some small working example that how to add data to XML at runtime.
Thanks
Gaurav
aschwin versteegden
Greenhorn
Posts: 3
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
DO You maybe have an example of the usage of DOM parsing mechanism
Ulf Dittmer
Rancher
Posts: 43081
77
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
An example of how to read an XML file and create a DOM Document from it can be
found here
.
Here
is an example of how to add elements to a DOM Document.
And finally,
here
is an example of how to write a DOM Document to a file.
Putting these pieces together you shoudl be able to read an XML file into a DOM Document, modify it, and then write it back to a file.
ram gaurav
Ranch Hand
Posts: 208
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot all.
My problem is solved with all your helps.
Thanks
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
DOM XML Parsing - Newbie
Change XML element using Java
How to save the content withen a table into a XML file?
RootElement is null
Namespace declaration using DOM
More...