Entity error in XML::XPATH
cognizant
created: 2006-03-03 06:19:28
Monks,

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

Re: Entity error in XML::XPATH
created: 2006-03-03 06:28:39
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.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.
Re: Entity error in XML::XPATH
created: 2006-03-03 16:06:19

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