在我的终端(linux/mac)上,我使用以下内容:
xmlstarlet ed -N ns=http://www.w3.org/2006/04/ttaf1 -d //ns:div[not(contains(@xml:lang,'Italian'))] "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"在windows (powershell)上,我真的不知道如何修复这个命令。我知道我需要使用$而不是@(因为powershell说使用$而不是@),但是包含有问题:
./xml.exe ed -N ns=http://www.w3.org/2006/04/ttaf1 -d //ns:div[not(contains($xml:lang,'Italian'))] "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"我甚至试过这个:
./xml.exe ed -N ns=http://www.w3.org/2006/04/ttaf1 -d //ns:div[not($xml:lang -contains'Italian')] "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"但我被“加载外部实体失败”“False”
发布于 2017-10-03 17:54:01
//ns:div[not(contains(@xml:lang,'Italian'))]是一个XPath表达式,它包含一些对各种shell都很特殊的字符,因此您应该用引号来保护它。使用双引号在bash、Powershell和cmd.exe中有效:
xmlstarlet ed -N ns=http://www.w3.org/2006/04/ttaf1 -d "//ns:div[not(contains(@xml:lang,'Italian'))]" "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"在使用bash或Powershell时,最好使用单引号;对于这些shell,需要使用单引号来防止$的扩展(尽管在XPath中使用这种方法相当先进):
xmlstarlet ed -N ns=http://www.w3.org/2006/04/ttaf1 -d '//ns:div[not(contains(@xml:lang,"Italian"))]' "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"注意,内部引号也需要交换。
https://stackoverflow.com/questions/46546960
复制相似问题