in reply to
XML Parse, Spanish Elements
Hi Senik,
Personnally I'm not such a big fan of XML::Simple since the parsing into different types is very unconfortable. For example if a node contains one subnode, the subnode is a hash element in the node itself, with nore children it becomes an array..this is just an example, but is just to show that the parsetree is very difficult to navigate.
Myself I rather use XML::XPath. Here you can use xpath queries to navigate to the nodes you want and the result is very straightforward.
for you this would become something like :
use XML::XPath;
use XML::XPath::XMLParser;
my $xp = XML::XPath->new(filename => 'test.xhtml');
my $nodeset = $xp->find('/noticias/noticia');
foreach my $noticia ($nodeset->get_nodelist) {
my ($title,$fulltext,$date,$time) =
( $noticia->find('titulo')->string_value,
$noticia->find('texto')->string_value,
$noticia->find('fecha')->string_value,
$noticia->find('hora')->string_value
)
}
Hope this helps you, it saved my life more than once :)