i want to be able to extract 'description/assertion' and 'command' from my code. Thanks so much! Ok, I figured out what is wrong. The text node is a child node of the element node lol.#!/usr/bin/perl -w use XML::DOM; use strict; my ($file, @rubbish) = @ARGV; if ($#ARGV > 0 ){ die; } my $parser = new XML::DOM::Parser; my $doc = $parser->parsefile($file); my $root = $doc->getDocumentElement(); print "$root\n"; scanner($root); sub scanner { my ($rt) = @_; my $i=0; foreach my $track ($rt->getElementsByTagName('track')){ foreach my $ping ( $track->getChildNodes()){ foreach my $nde ( $ping->getChildNodes()) { #my $nde = $nee->getNextSibling; if ($nde->getNodeType == ELEMENT_NODE) { #$log->info( $i.$nde->getTagName()); print $i++, " ELEMENT ", $nde->getNodeValue(), "\n"; } scanner( $nde ); } } } } } my file looks sth like this: <track name="linguist.segments" type="primary"> - <el index="0" start="0.44" end="0.56"> <attribute name="semantics">abstract</attribute> <attribute name="type">description/assertion</attribute> </el> - <el index="1" start="0.56" end="0.76"> <attribute name="semantics">abstract</attribute> <attribute name="type">command</attribute> </el> </track>
In reply to XML::DOM help by huiling
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |