【发布时间】:2012-09-30 11:38:28
【问题描述】:
我有以下xml
<?xml version="1.0" encoding="utf-8"?>
<Response>
<Function Name="GetSomethingById">
<something idSome="1" Code="1" Description="TEST01" LEFT="0" RIGHT="750" />
</Function>
</Response>
我想要<something> 节点的属性作为散列。我尝试如下
my $xpc = XML::LibXML::XPathContext->new(
XML::LibXML->new()->parse_string($xml) # $xml is containing the above xml
);
my @nodes = $xpc->findnodes('/Response/Function/something');
我期待有类似$nodes[0]->getAttributes 的东西,有什么帮助吗?
【问题讨论】:
标签: perl xml-parsing xml-libxml