Monks - I am using a vendor supplied perl module to access an API on a piece of hardware -
my $response = $s->invoke("disk-list-info");
returns a hash reference -
print $response; returns - NaElement=HASH(0x84b3408)
The hash is an XML document, the Data::Dumper looks like this - (very truncated)
print Dumper($response) returns - $VAR1 = bless( { 'content' => '', 'name' => 'results', 'children' => [ bless( { 'content' => '', 'name' => 'disk-details', 'children' => [ bless( { 'co +ntent' => '', 'na +me' => 'disk-detail-info', 'ch +ildren' => [ + bless( { + 'content' => '0b.29', + 'name' => 'name', + 'children' => [], + 'attrvals' => [], + 'attrkeys' => [] + }, 'NaElement' ), + bless( { + 'content' => '20000011:C6C99699:00000000:000000 +00:00000000:00000000:00000000:00000000:00000000:00000000', + 'name' => 'disk-uid', + 'children' => [], + 'attrvals' => [], + 'attrkeys' => [] + }, 'NaElement' ), + bless( { + 'content' => '13', + 'name' => 'bay', ........................
I'd like to get this document "loaded" into XML::Simple or XML::Twig so I can access the data more easily. I have tried ;
$xmldoc = XMLin($response); - This errors out with - read on filehandle failed: Can't locate object method "read" via packa +ge "NaElement" at /usr/lib/perl5/XML/LibXML.pm line 531. at /usr/lib/ +perl5/XML/LibXML/SAX.pm line 64 at /usr/share/perl5/XML/Simple.pm line 295
I have tried a whole bunch of variations on that, including
XMLin(\%response) - same error. \
Any ideas? Thanks, C

In reply to Send a hash reference to XML::Simple? by CRCarl

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.