in reply to parsing various xml responses
$root appears to be blank
No, it returns what it should
use XML::Bare; use Data::Dumper; my $page = '<?xml version="1.0" encoding="ISO-8859-1" ?> <PayoneerResponse> <Echo> <Status>000</Status> <Description>Echo Ok - All systems are up.</Description> </Echo> </PayoneerResponse>'; my $ob = new XML::Bare( text => $page ); my $root = $ob->parse(); local $Data::Dumper::Indent = 1; print(Dumper($root));
$VAR1 = { '_z' => 0, '_i' => -26338708, 'PayoneerResponse' => { '_z' => 178, '_i' => 47, 'value' => ' ', '_pos' => 1, 'Echo' => { '_z' => 158, '_i' => 66, 'Status' => { '_z' => 91, '_i' => 73, 'value' => '000', '_pos' => 3 }, 'value' => ' ', '_pos' => 2, 'Description' => { '_z' => 149, '_i' => 95, 'value' => 'Echo Ok - All systems are up.', '_pos' => 4 } } }, 'value' => ' ', '_pos' => 0 };
They never put an ending '</xml>'
Nor should they. The root element is named PayoneerResponse, not xml.
What would You use to parse the response from them?
Of the parsers I've tried, XML::LibXML is by far the fastest, it has a good interface, and actually handles namespaces correctly. It is my XML parser of choice.
|
|---|