in reply to Parsing XML::Simple
Hello Anonymous Monk,
The documentation for XML::Simple states that it should not be used in new code (see the STATUS OF THIS MODULE section). The author recommends alternatives such as XML::LibXML or XML::Twig. Perl XML::LibXML by Example looks like a good resource for getting started with XML::LibXML. Using information that I found there, I put together this example:
I hope you find this helpful.#!/usr/bin/env perl use strict; use warnings; use v5.10; use XML::LibXML; my $file = 'myxml.xml'; my $dom = XML::LibXML->load_xml(location => $file); foreach my $lang_set ($dom->findnodes('/DB/termEntry/langSet')) { my $lang = $lang_set->getAttribute('xml:lang'); foreach my $term_grp ($lang_set->findnodes('./termGrp')){ say '$lang : '. $term_grp->findvalue('./term'); } } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing XML::Simple
by Anonymous Monk on May 02, 2017 at 07:07 UTC | |
|
Re^2: Parsing XML::Simple
by Anonymous Monk on May 04, 2017 at 13:10 UTC |