Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
linux中的XML解析_Xml_Linux - Fatal编程技术网

linux中的XML解析

linux中的XML解析,xml,linux,Xml,Linux,大家好,请帮助我使用linux命令从以下xml中获取isDone的值 <content type="text/xml"> <s:dict> <s:key name="cursorTime">1969-12-31T19:00:00.000-05:00</s:key> <s:key name="delegate"></s:key> <s:key name="diskUsage">90112</s:key>

大家好,请帮助我使用linux命令从以下xml中获取isDone的值

<content type="text/xml">
<s:dict>
<s:key name="cursorTime">1969-12-31T19:00:00.000-05:00</s:key>
<s:key name="delegate"></s:key>
<s:key name="diskUsage">90112</s:key>
<s:key name="isDone">1</s:key>
</s:key>
</s:dict>
</content>

1969-12-31T19:00:00.000-05:00
90112
1

我知道这不是您所要求的,但由于Perl通常是默认安装的:

#!/usr/bin/perl

use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new();
$twig->parsefile ( 'your_xml' );
print $twig->get_xpath ( './s:dict/s:key[@name="isDone"]', 0 ) -> text;

s:
前缀在哪里定义?您的XML格式不正确-我认为这是复制粘贴错误?