我在$response_xml
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0" encoding="utf-8"?><wholeSaleApi><credentials><referenceNumber></referenceNumber></credentials><wholeSaleOrderResponse><statusCode>666</statusCode><description>Object reference not set to an instance of an object.</description></wholeSaleOrderResponse></wholeSaleApi></string>
当我使用
解析它时my $xs = XML::Simple->new();
my $xmlDS = eval{ $xs->XMLin($response_xml) };
我得到以下数据结构
$xmlDS = {
'xmlns' => 'http://schemas.microsoft.com/2003/10/Serialization/',
'content' => '<?xml version="1.0" encoding="utf-8"?><wholeSaleApi><credentials><referenceNumber></referenceNumber></credentials><wholeSaleOrderResponse><statusCode>666</statusCode><description>Object reference not set to an instance of an object.</description></wholeSaleOrderResponse></wholeSaleApi>'
};
如何从中获取content
部分?
答案 0 :(得分:3)
你得到的是一个哈希引用。您可以使用以下语法来获取特定键:
my $content = $xmlDS->{content};