BigBear has asked for the wisdom of the Perl Monks concerning the following question:
how do I access xml attribute details using XML::Simple and/or XML::Mini::Document or XML::LibXML ?
I am trying to understand and compare 4 ways in which I could use perl cpan xml modules to extract some info from a bunch of given XML files.
I have written some proof of concept code using XML::XPath and am left wondering how this "simple" task would be solved by using on of the other XML modules? I am a beginner in some ways and learn best by observing a problem and then copying that sample and modyfying it to my needs.
my perl XML::XPath code #!/usr/bin/perl #file: show-barcodes-with-XML-XPath.pl #!/usr/bin/perl use XML::XPath; my $file = "00000002.TIF.xml"; my $xp = XML::XPath->new(filename => $file); my $barcode_code39 = $xp->find('/barcodes/source/index/symbol[@type="C +ODE-39"]/data'); my $barcode_qrcode = $xp->find('/barcodes/source/index/symbol[@type="Q +R-Code"]/data'); $barcode_code39 = substr($barcode_code39, 0, 10); print ("Code 39: ", $barcode_code39, "\n"); print ("QR-Code: ", $barcode_qrcode, "\n"); #print ("processed: " . $file . "\n"); #file: 00000002.TIF.xml <barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'> <source href='00000002.TIF'> <index num='0'> <symbol type='QR-Code' quality='1'><data><![CDATA[0037000249]]></data> +</symbol> <symbol type='CODE-39' quality='102'><data><![CDATA[0037000249P]]></da +ta></symbol> </index> </source> </barcodes>
How would I employ XML::Simple to do the "same" thing ?
And how would I write the same thing using XML::Mini::Document ?
And lastly how would I write the same thing using XML::LibXML ?
Thanks for any insights into how this would be done using one of the above
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: care to illustrate use of xml cpan modules?
by tobyink (Canon) on Jul 09, 2012 at 22:59 UTC | |
Re: care to illustrate use of xml cpan modules?
by mirod (Canon) on Jul 10, 2012 at 04:45 UTC | |
Re: care to illustrate use of xml cpan modules?
by Anonymous Monk on Jul 09, 2012 at 21:19 UTC | |
Re: care to illustrate use of xml cpan modules?
by Mr. Muskrat (Canon) on Jul 10, 2012 at 18:37 UTC | |
Re: care to illustrate use of xml cpan modules?
by grantm (Parson) on Jul 11, 2012 at 03:12 UTC |