• 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

Creating nodes in a document

 
Greenhorn
Posts: 9
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to XML and I am trying to create an xml document.



In java to form the above document I did the following:



After which I am basically stuck - how would I create a node inside the document (I clearly see this is basic and simple) .... but whichever tutorial I go through wont give me an answer for this (there are parsers to read and convert xmls to DOM back and forth - but how would I form just a simple xml

I am expecting something like



I do not want to use external jars/libs/apis like XStream or castor to do the above.

How would I do the above?

thank you
Guru
[ November 22, 2006: Message edited by: Guru Vasu ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<root> <element> <name>Name</name> <value>Value</value> </element></root>

Create a document.Create an element with name root and append to document, continue the same to create the structure and for adding Name , create text node and append to element name.

For creating various xml nodes use Document as factory.(it has all the required methods.)
 
Guru Vasu
Greenhorn
Posts: 9
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Rahul



The above produced the desired output.

Could you please check and reply if I am doing what you asked me to? and if I can cutshort any of the above calls?

Thank you again Rahul

Guru
 
He does not suffer fools gladly. But this tiny ad does:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic