"...it was determined that XML::Simple just wasn't the right answer."

Well, sometimes XML::Simple is not enough, but in this case i think you didn't spend enough time in research. Here is how i imagine you tested out XML::Simple:
use XML::Simple; use Data::Dumper; my $ref = XMLin(\*DATA); print Dumper $ref; __DATA__ <?xml version="1.0" encoding="UTF-8"?> <list> <item> <name>item_name_1</name> <working>yes</working> <uptime>5</uptime> <downtime></downtime> </item> <item> <name>item_name_2</name> <working>yes</working> <uptime>5</uptime> <downtime></downtime> </item> </list>
And the results?
$VAR1 = { 'item' => { 'item_name_1' => { 'uptime' => '5', 'downtime' => {}, 'working' => 'yes' }, 'item_name_2' => { 'uptime' => '5', 'downtime' => {}, 'working' => 'yes' } } };
So yes, if this is what you did then i can definitely see how you would prematurely dismiss the module as the "wrong answer". But, if you had RTFM'ed, you would have seen that KeyAttr is taking the name tags and making them hash keys to each row of XML data. By simply changing the constructor's args to:
my $ref = XMLin(\*DATA,KeyAttr=>[]);
the results are now:
$VAR1 = { 'item' => [ { 'uptime' => '5', 'downtime' => {}, 'working' => 'yes', 'name' => 'item_name_1' }, { 'uptime' => '5', 'downtime' => {}, 'working' => 'yes', 'name' => 'item_name_2' } ] };
And look how trivally easy it is to get the parts:
print $_->{name} for @{$ref->{item}};

"I needed more control of the output anyway."

What does that mean? Personally, i don't think you are parsing XML, i think you are parsing something that merely looks like XML. You asked the best way to parse XML, we told you. You then added more requirements, but i still say you are wasting time. Do me a favor, keep track of how many hours you spend maintaining your 16 lines of "parser" code (correcting mistakes, adding new features) and compare that to the one hour it takes to install XML::Simple and read the manual.

Now please don't get me wrong, i wish you success. I have worked for shops that reinvent every wheel along the way and they all suffer because of it. It is a foolish, egotistical, and wasteful methodology. Listen to Maverick.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to 5Re: Parsing XML into a Hash by jeffa
in thread Parsing XML into a Hash by mcogan1966

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.