Ok, so taking a stab at XML::Rules and the first thing I find in my XML is a namespace tag prefixed on all of my data elements.

<ns2:Height Units="inches">1.00</ns2:Height> <ns2:Length Units="inches">1.00</ns2:Length> <ns2:Width Units="inches">1.00</ns2:Width> <ns2:Weight Units="pounds">0.01</ns2:Weight>

In my rules, do I refer to this tag as "ns2:Height" or as "Height" somehow accounting for the namespace?

Update:

And do I need to deal with every tag in the XML? For example, if my XML is:

<ns2:Item> <ns2:Attributes> <ns2:Height Units="inches">1.00</ns2:Height> <ns2:Length Units="inches">1.00</ns2:Length> <ns2:Width Units="inches">1.00</ns2:Width> <ns2:Weight Units="pounds">0.01</ns2:Weight> </ns2:Attributes> </ns2:Item>

Can I have rules that just deal with Height, Length, Width, Weight, etc? Or do I have to have rules for Item and Attributes to get to the other attributes? I am unclear from reading the XML::Rules documentation. The example has a _default tag which looks like it is supposed to deal with all items not otherwise specified but so far, I am only getting Item in my output as:

0 HASH(0x36a9310) 'Item' => undef

The rules that I am using are:

my @rules_prod = ( _default => sub { $_[0] => $_[1]->{_content}}, 'ns2:Weight' => sub { weight => $_[1]->{_content} }, 'ns2:Height' => sub { height => $_[1]->{_content} }, );

In reply to Re: hashref with(out) arrays by bfdi533
in thread hashref with(out) arrays by bfdi533

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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, details, 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, summary, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.