濾除元件如何過濾掉不具有帶有魔術值的屬性並保持文檔的其餘部分的某些類型的元素?所有這些使用xmlstarlet
?xmlstarlet:具有屬性
我得遠是什麼:
cat <<EOF> database.xml
<?xml version="1.0"?>
<database>
<some name="A" />
<some name="B" />
<some name="C" />
<text>this is some text to be applied...</text>
<project>
<test deeper="structure"/>
</project>
</database>
EOF
和
xmlstarlet sel -t -m "*" -c "*[not(self::some[@name != 'A'])]" database.xml
產生
<some name="A"/><text>this is some text to be applied...</text><project>
<test deeper="structure"/>
</project>
但這個隱藏我的珍貴<database>
tag
。除了壓痕,這是沒有問題的......而當<some>
都不是<database>
嫡系的<project>
例如孩子的不起作用。
我想要得到的是數據庫,因爲它是,但所有<some>
刪除除了了一個名爲A
:
<database>
<some name="A" />
<text>this is some text to be applied...</text>
<project>
<test deeper="structure"/>
</project>
</database>
問候
你想回到什麼?問題並不清楚。 –
的XPath像* //數據庫/ *」可能工作職位詳細信息'不是嫡系...' –
SIslam