xmlstarlet-从文件附加值会引起奇怪的问题
test.xml
<?xml version="1.0"?>
<config xmlns:foo="http://www.example.org/" xmlns:bar="http://www.example.org">
<actors>
<actor id="1">Christian Bale</actor>
<actor id="2">Liam Neeson</actor>
<actor id="3">Michael Caine</actor>
</actors>
<foo:singers>
<foo:singer id="4">Tom Waits</foo:singer>
<foo:singer id="5">B.B. King</foo:singer>
<foo:singer id="6">Ray Charles</foo:singer>
</foo:singers>
</config>
append.txt
<mint>
<enabled>true</enabled>
<cronExp>0 0 /5 * * ?</cronExp>
<syncDeletes>true</syncDeletes>
<syncProperties>true</syncProperties>
<repoKey>example</repoKey>
<url>https:// example.com/bar</url>
<socketTimeoutMillis>15000</socketTimeoutMillis>
<enableEventReplication>true</enableEventReplication>
<syncStatistics>false</syncStatistics>
</mint>
我想在/config/foo:singers
之后添加append.txt的内容
尝试-
xml ed -a /config/foo:singers -t text -n mints -v $(cat append.txt) test.xml
-
失败failed to load external entity "<enabled>true</enabled>"
xml ed -a /config/foo:singers -t text -n mints -v "$(cat append.txt)" test.xml
<
,>
等的实体字符从文件中为标签附加内容的正确方法是什么?
答案 0 :(得分:1)
对于在这里偶然发现的其他人来说,这对我有用->
xml ed -a /config/foo:singers -t text -n mints -v "$(cat append.txt)" test.xml | xmlstarlet unesc | xml fo
xmlstarlet unesc
很重要-http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html#idm47077139540960