• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java API's for editing XML document

 
Abhijeet Deshmukh
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


I want to edit a XML document from a java application which api's should i use for this. As going through docs i found

javax.xml.parser : Provides common interface fro diff sax & DOM parser.

but can we edit xml file through these api's.
kindly send me reply as soon as possible


Thanks & Regards,
Abhijeet
 
JuanP barbancho
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think that the fastest for performance is SAXParser, but you need create the complete tree and object.

I think that JDOM is good for java programmer. I unkown if this api is supported.
 
David Patterson
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use JDOM, you will wind up with a Document object. You can either use a SAXParser (usually this is the best way to go if your input is an XML file) or a DOMParser (if you already have the DOM Object).

With a Document, you can easily edit:
- change the text string in an element
- add new elements or attributes
- delete elements or attributes
- change the contents of an attribute

Dave Patterson
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to use JDOM - still a non-standard API. The standard toolkit in the Java SDK since version 1.4 gives you all you need to change, add or remove Elements, Nodes and attributes in a org.w3c.dom.Document object.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic