Question

I know that you can get the line number and column number from a org.xml.sax.SAXParseException.

Is it possible to get the line number and column number from a org.w3c.dom.Node?

Was it helpful?

Solution

No (at least not with the standard DOM API).

DOM trees are not related to a specific serialization. In fact, there are various ways to output a DOM tree, and they might give different results for an element line number.

When you parse an XML document into a DOM, you might be able to get a SAXParseException with a line number if there is an error. But the information is lost after parsing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top