gpt4 book ai didi

Linux 下的 XML 解析

转载 作者:太空宇宙 更新时间:2023-11-04 03:39:53 25 4
gpt4 key购买 nike

大家好,请帮助我使用 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>

最佳答案

我知道这并不完全符合您的要求,但由于 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;

关于Linux 下的 XML 解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30190616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com