I have a program which reads an XML file using the DOM functions:
$doc = new DOMDocument('1.0');
$doc->load("myFile.xml");
As I traverse the nodes in this document, is there a way to tell which line of the input file the node was defined on?
For example:
1: <!-- myFile.xml -->
2: <foobar>
3: <foo>FOO</foo>
4: <bar>BAR</bar>
5: </foobar>
and the PHP:
$xp = new DOMXPath($doc);
$bars = $xp->query("//bar");
$myBar = $bars[0];
echo "The first <bar> element is on line " . performMagicHere(); // 4