How to get the line number an xml element is on via the Java w3c dom api
Posted
by Benju
on Stack Overflow
See other posts from Stack Overflow
or by Benju
Published on 2010-04-30T20:19:31Z
Indexed on
2010/05/01
8:57 UTC
Read the original article
Hit count: 199
Is there a way to lookup the line number that a given element is at in an xml file via the w3c dom api?
My use case for this is that we have 30,000+ maps in kml/xml format. I wrote a unit test that iterates over each file found on the hard drive (about 17GB worth) and tests that it is parseable by our application. When it fails I throw an exception that contains the element instance that was considered "invalid". In order for our mapping department (nobody here knows how to program) to easily track down the typo we would like to log the line number of the element that caused the exception.
Can anybody suggest a way to do this? Please note we are using the W3C dom api included in the Android 1.6 SDK.
© Stack Overflow or respective owner