CRCarl has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: Send a hash reference to XML::Simple?
by Corion (Patriarch) on Jan 03, 2008 at 17:19 UTC

    XML::Simple works with XML files. What you get back is an object of class NaElement. Consult your documentation on NaElement (possibly by typing perldoc NaElement at the command prompt) on how to use it. In any case, you don't need to "read in" the object or do anything special to use it as a Perl object, except that without reading the documentation, you won't be able to know what to do with the object.