If the code below doesn't answer your question (I can't really tell what the question is without some executable code that shows the problem), adjust it to show your problem and repost.
use strict; use warnings; use XML::LibXML; my $xml1 = <<XML; <doc> <id> <elements> <element1>matching text</element1> <element2>other text</element2> <element3>other text</element3> </elements> </id> </doc> XML my $xml2 = <<XML; <doc> <id> <elements> <element1>matching text</element1> <element2>another text</element2> <element3>other text</element3> </elements> </id> </doc> XML my $parser = XML::LibXML->new(); my $doc1 = $parser->parse_string($xml1); my $doc2 = $parser->parse_string($xml2); my @doc1Nodes = map {[$_->textContent(), $_->nodeName()]} grep {$_->nodeName() =~ /^element/} map {$_->childNodes()} $doc1->findnodes('//doc/id/elements'); my @doc2Nodes = map {[$_->textContent(), $_->nodeName()]} grep {$_->nodeName() =~ /^element/} map {$_->childNodes()} $doc2->findnodes('//doc/id/elements'); for my $index (0 .. $#doc1Nodes) { print "Mismatch in $doc1Nodes[$index][1]\n" if $doc1Nodes[$index][0] ne $doc2Nodes[$index][0]; }
Prints:
Mismatch in element2
In reply to Re: print specific XML node number
by GrandFather
in thread print specific XML node number
by zak_s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |