以下情况正在发生:
按预期工作的文件:
列出 xml 中的内容:
# xmlstarlet el -a table.xml
table
table/rec
table/rec/@id
table/rec/numField
table/rec/stringField
table/rec
table/rec/@id
table/rec/numField
table/rec/stringField
table/rec
table/rec/@id
table/rec/numField
table/rec/stringField
选择特定元素:
# xmlstarlet sel -t -v "//table/rec/numField" table.xml
123
346
-23
原始数据:
#cat table.xml
<?xml version="1.0" encoding="UTF-8"?>
<table>
<rec id="1">
<numField>123</numField>
<stringField>String Value</stringField>
</rec>
<rec id="2">
<numField>346</numField>
<stringField>Text Value</stringField>
</rec>
<rec id="3">
<numField>-23</numField>
<stringField>stringValue</stringField>
</rec>
</table>
下一次运行 test.xml
# xmlstarlet el -a test.xml
filelists
filelists/@xmlns
filelists/@packages
filelists/package
filelists/package/@pkgid
filelists/package/@name
filelists/package/@arch
filelists/package/version
filelists/package/version/@epoch
filelists/package/version/@ver
filelists/package/version/@rel
filelists/package/file
filelists/package/file
filelists/package/file
filelists/package/file
filelists/package/file/@type
查询方式同上一个:
# xmlstarlet sel -t -v "//filelists/package/file" test.xml
#
文件内容:
#cat test.xml
<?xml version="1.0" encoding="UTF-8"?>
<filelists xmlns="http://linux.duke.edu/metadata/filelists" packages="8">
<package pkgid="fc2a76ba4e6e0b2bc704b9e7bcb205ca1c11e93b" name="bigtop-utils" arch="noarch">
<version epoch="0" ver="0.4+300" rel="1.cdh4.0.1.p0.1.el6"/>
<file>/etc/default/bigtop-utils</file>
<file>/usr/libexec/bigtop-detect-javahome</file>
<file>/usr/share/doc/bigtop-utils-0.4+300/LICENSE</file>
<file type="dir">/usr/share/doc/bigtop-utils-0.4+300</file>
</package>
</filelists>
I guess I don't get something here.
为什么我不能显示那些文件标签的内容?我需要以某种方式逃避它吗?