I am using RPC::XML and parsing request xml using below code and request xml.
use RPC::XML::ParserFactory 'XML::Parser';
my $P = RPC::XML::ParserFactory->new();
my $parse_data = $P->parse($xml_data);
print Dumper($parse_data);
Request xml:
<methodCall>
<methodName>get_topic</methodName>
<params>
<param>
<value>
<string>163397</string>
</value>
</param>
<param>
<value>
<i4>0</i4>
</value>
</param>
<param>
<value>
<i4>19</i4>
</value>
</param>
<param>
<value>
<string>ANN</string>
</value>
</param>
</params>
</methodCall>
I have get object data:
bless( {
'name' => 'get_topic',
'args' => [
bless( do{\\(my $o = '163397')}, 'RPC::XML::string' ),
bless( do{\\(my $o = '0')}, 'RPC::XML::i4' ),
bless( do{\\(my $o = '19')}, 'RPC::XML::i4' ),
bless( do{\\(my $o = 'ANN')}, 'RPC::XML::string' )
]
}, 'RPC::XML::request' );
After I have done print Dumper($parse_data->args);
and get below args object data:
bless( {
$VAR1 = [
bless( do{\\(my $o = '163397')}, 'RPC::XML::string' ),
bless( do{\\(my $o = '0')}, 'RPC::XML::i4' ),
bless( do{\\(my $o = '19')}, 'RPC::XML::i4' ),
bless( do{\\(my $o = 'ANN')}, 'RPC::XML::string' )
];
Now how to get values from this args object data? please help!
Untested, but according to the documentation this should work:
my $args = $parse_data->args;
for my $arg (@$args) {
print $arg->type, ": ", $arg->value, "\n";
}
In particular read the Message Classes documentation which explains the methods of RPC::XML::request
and Data Classes which explains RPC::XML::string
and friends.