in reply to Xpath and line number

I don't believe you can get that information with XML::XPath.

Did you read the XML::Twig FAQ I would like XML::Twig to report line/column number in the original file? The solution given should give you the line number of the opening tag.