Sam*_*ron 3 perl xml-parsing xml-libxml
我有以下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>
Run Code Online (Sandbox Code Playgroud)
我希望<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');
Run Code Online (Sandbox Code Playgroud)
我希望有$nodes[0]->getAttributes
任何帮助吗?
my %attributes = map { $_->name => $_->value } $node->attributes();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
139 次 |
最近记录: |