This Example shows you how to Change the Content of a node in a DOM document. JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used to create new DOM parsers. These are some of the methods used in code given below for adding attribute:-
Element root = doc.getDocumentElement():-direct access to the root of the DOM document.
NodeList childnodelist = root.getChildNodes():-created a childnodelist and get the collection of child nodes of this node.
Xml code for the program generated is:-
Output of the program:-
Old e-mail id: [email protected]
New e-mail id: @Rose.com
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: August 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles