XML : How to filter/narrow XML in Perl to ignore unwanted child elements?

Say I have the following XML structure (mock) that begins:

  <site defaultDomain="www.somedomain.com">      <supported-locales>          <locale id="sometext"/>      </supported-locales>      <next-child-of-site>      ...  </site>    

I am using Mojo::DOM and trying to get only the 'id' text of locale (a child of <supported-locales>) and ignore the other child elements of <site>

  # Parse XML  my $dom = Mojo::DOM->new->xml(1)->parse($xml);    for my $e ($dom->find('site[defaultDomain')->each) {      say $e->children->join();  }    

So I get this far, but am stuck on how to filter the children to <supported-locales> and then <locale> only. Suggestions? I'm new to XML processing with Mojo::DOM.

No comments:

Post a Comment