Perl XMLin未正确解析XML
我在Perl XMLin未正确解析XML,perl,perl-module,perl-data-structures,Perl,Perl Module,Perl Data Structures,我在$response\u XML <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0" encoding="utf-8"?><wholeSaleApi><credentials><referenceNumber></referenceNu
$response\u 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>
我得到以下数据结构
$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>'
};
$xmlDS={
'xmlns'=>'http://schemas.microsoft.com/2003/10/Serialization/',
“content'=>“666对象引用未设置为对象的实例。”
};
如何从中获取
内容
部分 您得到的是一个散列引用。您可以使用以下语法访问特定键:
my $content = $xmlDS->{content};
得到的是散列引用。您可以使用以下语法访问特定键:
my $content = $xmlDS->{content};
问题的主题是
XML::Simple
无法正确解析XML,但问题的主体只是询问如何从返回的哈希中访问元素。是哪一个?问题的主题是XML::Simple
不能正确解析XML,但问题的主体只是询问如何从返回的哈希中访问元素。这是哪一种?访问内容的另一种方式:my$content=${$xmlDS}{content};还有一种访问内容的方法:my$content=${$xmlDS}{content};