in reply to Assigning variables and persistence using Lib::LibXML::Reader
Hi,
Use the twig good buddy, no matter how big the file
#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; my $xml = q{<product> <name>5 Spoke Wheel</name> <description>Reconditioned OEM</description> <price>123.45</price> <buyurl>http://www.foo.com</buyurl> <imageurl>http://www.foo.com/foo.jpg</imageurl> </product>}; $xml = join '', '<root>',$xml, $xml, $xml, '</root>'; XML::Twig->new( twig_roots => { '/root/product' => sub { print join "\n", $_->path, $_->first_child('name' )->text, $_->first_child('price' )->text, $_->first_child('buyurl' )->text, "\n"; }, }, )->parse( $xml );
|
|---|