Here's an XML::Rules solution, though I'm not sure if there may or may not be more than one label per category, or more than one keyword per keywords. I'm assuming "may not", but easy enough to fix if "may" (I would add 'as array no content' rules for label and keyword, and then assume arrays in the parent node's code): use strict;
use warnings;
use XML::Rules;
my $xml = <<XML;
<?xml version="1.0" encoding="UTF-8"?>
<results>
<url>--removed--</url>
<language>english</language>
<text>---removed---</text>
<taxonomy>
<category>
<label>/vehicle brands/jeep</label>
</category>
<category>
<label>/travel</label>
</category>
</taxonomy>
<keywords>
<keyword>
<text>rear extended bumpstops</text>
</keyword>
</keywords>
</results>
XML
my @rules = (
category => sub {
my $r = $_[1];
print "Category: $r->{label}\n";
},
keywords => sub {
my $r = $_[1];
print "Keywords: $r->{text}\n";
},
keyword => 'pass no content',
_default => 'content',
);
my $xr = XML::Rules->new( rules => \@rules );
$xr->parse($xml);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|