in reply to How to find the value of the first and last occurence of an XML node?

If you use an XPath capable parser/query engine, this is very easy, as getting the first and last node is just:

my $doc = ...; # read/parse XML file my @first = $doc->findNodes('./*[1]'); my @last = $doc->findNodes('./*[last()]');

This is one of the huge advantages that XML (and XPath) buy you - your code gets much clearer and quicker to write.

  • Comment on Re: How to find the value of the first and last occurence of an XML node?
  • Download Code