Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Bug in XML::Parser

by graff (Chancellor)
on Oct 23, 2013 at 04:43 UTC ( #1059275=note: print w/replies, xml ) Need Help??


in reply to Bug in XML::Parser

Actually, depending on what you're actually trying to accomplish, something other than XML::Parser might be a better fit. In particular, XML::LibXML is vastly superior (IMHO). There's more documentation to look at, but in my experience, it's worth the effort, especially when you get to the XPath stuff.

Here's how I'd use XML::LibXML for that same simple example (to print out just the contents of "Amount" tags):

#!/usr/bin/perl use strict; use warnings; use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parser->parse_file( "org1.xml" ); my $xpath = XML::LibXML::XPathContext->new( $doc ); for my $node ( $xpath->findnodes( '//Amount' )) { print $node->textContent, "\n"; }
It doesn't get much simpler than that!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059275]
help
Chatterbox?
[LanX]: Thanks Many thanks YM... it was already supposed to be encoded, I'll see tomorrow
[Your Mother]: I am entirely skeptical the wall will happen… but this country does love its boongdoggles now and then. :P
[Your Mother]: Did I tell or show you? There is a leucistic Turkey Vulture around here all the time. I have a couple decent pictures.
[Your Mother]: Pure white (well, dirty white :P)
[erix]: as a kid I had a painted bunting -- beautiful
[Your Mother]: I would love to see one. It would be a lifer.
[Your Mother]: Wait… maybe I did see one last year…
[Your Mother]: I saw what I thought was a Cuban trogon but they are too impossibly rare / never seen in the US. That guy might have been what I actually saw.
[LanX]: Good Night guys!
[LanX]: :)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2017-01-20 01:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.