Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.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
从xml中提取字符串_Xml_Bash - Fatal编程技术网

从xml中提取字符串

从xml中提取字符串,xml,bash,Xml,Bash,从以下xml: <?xml version="1.0"?> <broker xmlns="some-ns.com" name="some-ns"> <queue name="US.PUT.INTERNAL.FULFILLMENT.REMEDY" enable="true" process="/u/is/bin/RmdyCrtUtil.sh" /> <queue name="US.DATA.MINING.IN" enable="tr

从以下xml:

<?xml version="1.0"?>
    <broker xmlns="some-ns.com" name="some-ns">
    <queue name="US.PUT.INTERNAL.FULFILLMENT.REMEDY" enable="true" process="/u/is/bin/RmdyCrtUtil.sh" />
    <queue name="US.DATA.MINING.IN" enable="true" process="/u/is/bin/ferret_trigger" />
    <queue name="US.PHOTO.INPUT" enable="true" process="/u/is/bin/spx0400b.sh" />
    <queue name="US.OPTICAL.INPUT" enable="true" process="/u/applic/optical/svc_web_proc.sh" />
    <queue name="US.TLGO.DATA.QUEUE" enable="true" process="/u/is/smb0010b.sh" />
</broker>

对于给定的数据和即时解决方案,您可以使用:


cat test.xml | grep'愿意向我们展示您的尝试吗?如果您想按照简单、特定的格式提取简单数据,
regex
标记中有很多类似的问题。类似于
的东西,我建议使用XML解析器。使用bash工具,复杂的情况很容易失败删除不相关的根属性以提高可读性,使名称空间更具可读性。修复了属性中的错误语法。固定语法。
US.PUT.INTERNAL.FULFILLMENT.REMEDY
US.DATA.MINING.IN
US.PHOTO.INPUT
US.OPTICAL.INPUT
US.TLGO.DATA.QUEUE
/u/is/bin/RmdyCrtUtil.sh
/u/is/bin/ferret_trigger
/u/is/bin/spx0400b.sh
/u/applic/optical/svc_web_proc.sh
/u/is/smb0010b.sh
$ cat test.xml |grep '<queue'|cut -d '"' -f2;cat test.xml |grep '<queue'|cut -d '"' -f6
US.PUT.INTERNAL.FULFILLMENT.REMEDY
US.DATA.MINING.IN
US.PHOTO.INPUT
US.OPTICAL.INPUT
US.TLGO.DATA.QUEUE
/u/is/bin/RmdyCrtUtil.sh
/u/is/bin/ferret_trigger
/u/is/bin/spx0400b.sh
/u/applic/optical/svc_web_proc.sh
/u/is/smb0010b.sh