I wanna extract specific elements from the xml file (Example: h1/title). I have tried using XML:XPATH as follows:
my $str = $ARGV[0];
my $xp = XML::XPath->new(xml => "$str");
my $nodeset = $xp->find('//h1/title'); #
foreach my $node ($nodeset->get_nodelist)
{my $tag=XML::XPath::XMLParser::as_string($node);
print "$tag\n";}
I got parsing error b'cos of entities. Hence i've replaced all the entities with some other characters and after extracting all the tags i've replaced back the original entites. I got the result which i need.
I'm sure that there is a better way to do this. Could u pls suggest me the better way?
Cheers
--C
I got parsing error b'cos of entities.What error message (important, copy/paste)?
I'm sure that there is a better way to do this. Could u pls suggest me the better way?Without seeing sample input and an error message (node 172086), the best answer you can hope for is to "fix" your XML so its properly formed :/
update: node 105914 might interest you.
That document is not well-formed XML. Named entities like É have to be defined in a DTD, but you did not supply any, so the parser correctly complains.
Makeshifts last the longest.
perlmonks.org content © perlmonks.org and Aristotle, cognizant, PodMaster
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03