Additional Details
I am new in xml .Actually i am trying to build DOM Object of a file whose path is given .So that it can be used in display ,edit, traverse functions...
Problem is that variable doc is getting a null value.Why is it so?
Santhosh ayiappan wrote:Execute the code and share the output/errors if any....
When I run this code I got this error.
run: Exception in thread "main" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl cannot be cast to javax.swing.text.Document at common.parseXmlFile.parseXmlFile(parseXmlFile.java:28) at common.parseXmlFile.main(parseXmlFile.java:59) Java Result: 1
s ithu wrote:Problem is that variable doc is getting a null value.Why is it so?
That is simply because the "value" of a Document node is null. Check out the API documentation of org.w3c.dom.Node to confirm that. But you aren't going to be using the "value" of the Document node anyway, so there is no need to spend any time worrying about it. It isn't a problem.
If you have succeeded in creating a org.w3c.dom.Document DOM then you can use the methods in the standard library to "navigate" around in the DOM.
You can also use XPath, which can give you a convenient way of expressing navigation in a DOM, and XSLT which can be convenient for creating new documents from the DOM.