Creating a simple Java XML DOMCreating a simple Java XML Document Object Model is very easy if you use the appropriate imports and use the appropriate classes and methods. The following import statements are to be used to use the appropriate classes and methods to work with the XML document. import org.w3c.dom.Document; Creating a document object that can load the XML document involves three steps, and the following code will give you an idea on how to create such a document object. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Once you have created the document object, there are methods available in the document object to work with the XML document. The method getDocumentElement().getNodeName() can be used to get the root element name of the XML document that is loaded in the document object. The getElementsByTagName() method can be used to get all the names of the elements that is specified as an string argument to that method.Lots of complete code samples are available in the internet that uses these methods to work with the XML document.
|
|
||
|
|||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.