4

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?

FabienB
  • 1,104
  • 2
  • 11
  • 22
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202

1 Answers1

3

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.

Damien
  • 3,060
  • 1
  • 25
  • 29