XPath to Line Number?
- From: Andrew <acheong87@xxxxxxxxx>
- Date: Tue, 26 Jun 2007 11:39:43 -0700
In one sentence: Given an XML file and an XPath pointing to a certain
node, how can I find the line-number of that node in the original XML
file?
I am building a script that reads an XML file, checks it against a
bunch of validation rules, and outputs any errors and/or warnings.
Currently, I read the XML file via XML::XPath->new(filename =>
$filename), but I am open to alternative suggestions. When I do find
an error (for example, a certain attribute may have an invalid keyword
for its value), I want to print the line number of the original XML
file in which this error occurred.
Searching on the web, I found several references to XML::Twig. I was
wondering if anyone could offer suggestions or advice about XML::Twig
or any other modules that could help.
Thanks in advance!
.
- Follow-Ups:
- Re: XPath to Line Number?
- From: mirod
- Re: XPath to Line Number?
- From: MM
- Re: XPath to Line Number?
- Prev by Date: Re: Help with validating XML (DTD or Schema) with PERL
- Next by Date: Re: XPath to Line Number?
- Previous by thread: Re: Help with validating XML (DTD or Schema) with PERL
- Next by thread: Re: XPath to Line Number?
- Index(es):
Relevant Pages
|