in reply to care to illustrate use of xml cpan modules?
With XML::LibXML it's pretty similar. The biggest change is that libxml sticks rigidly to the XPath spec and forces you to use a namespace prefix for matching element names in the 'http://zbar.sourceforge.net/2008/barcode' namespace.
use XML::LibXML; my $file = '00000002.TIF.xml'; my $xp = XML::LibXML::XPathContext->new( XML::LibXML->load_xml(location => $file), ); $xp->registerNs(b => 'http://zbar.sourceforge.net/2008/barcode'); my $barcode_code39 = $xp->find('/b:barcodes/b:source/b:index/b:symbol[ +@type="CODE-39"]/b:data'); my $barcode_qrcode = $xp->find('/b:barcodes/b:source/b:index/b:symbol[ +@type="QR-Code"]/b:data'); $barcode_code39 = substr($barcode_code39, 0, 10); print ("Code 39: ", $barcode_code39, "\n"); print ("QR-Code: ", $barcode_qrcode, "\n");
|
|---|