2017-03-15 19 views
1

我想用bash中的腳本使用工具XMLStarlet編輯我的xml文件。 所以我想刪除我的文件的完整標籤,我的問題是在我的命令syntaxe如下:使用XMLStarlet在bash腳本中引號之間的空格字符

xmlstarlet ED -d「/屬性/結構名= \」偏好\「」 $ 1

標記是< 結構名稱= 「偏愛」>

我的錯誤是: 的XPath錯誤:無效表達 /屬性/結構 「 」名稱=「 偏愛」 電子rror指向第一個報價(「)

我嘗試插入引號,反斜槓使空格字符可以接受,但我沒有找到使其工作的方式。 有人可以幫助我解決這個問題嗎?我還沒有找到關於此的話題。

由於通過提前

+0

你能充分提供'XML'片段? – Inian

回答

0

來源:

<properties> 
    <bla name="preference" > 
    </bla> 
    <structure name="preference" > 
    </structure> 
    <structure name="xxx" > 
    </structure> 
</properties> 

的:

xmlstarlet ed -d '/properties/structure[@name="preference"]' 

產生

<?xml version="1.0"?> 
<properties> 
    <bla name="preference"> 
    </bla> 
    <structure name="xxx"> 
    </structure> 
</properties> 
相關問題