带有命名空间属性替换的 xmlstarlet
xmlstarlet with namespaces attribute replacement
我无法用 xmlstarlet 替换属性。
dog.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<rabbit:connection-factory id="mqConnectionFactory"
host="localhost"
port="9999" />
</beans>
已尝试以下多种变体:
xmlstarlet ed -N B="http://www.springframework.org/schema/beans" -N R="http://www.springframework.org/schema/rabbit" --update "/B/R:connection-factor/@host" --value "myserver" dog.xml
我错过了什么?我已经为 B 和 R 的许多变体尝试了 beans 和 B:beans,但我认为没有选择正确的元素。
用你的例子解决 failed to load external entity
问题的两种方法:
xmlstarlet edit --update "//@host" --value "myserver" file.xml
或
xmlstarlet edit --update "//*[local-name()='connection-factory']/@host" --value "myserver" file.xml
具有完整的命名空间声明,
xmlstarlet ed \
-N B="http://www.springframework.org/schema/beans" \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/B:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
或者,使用 xmlstarlet
快捷方式,根据
user guide:
xmlstarlet ed \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/_:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
找出拼写错误:您的命令丢失
connection-factory
.
中最后的 y
我无法用 xmlstarlet 替换属性。
dog.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<rabbit:connection-factory id="mqConnectionFactory"
host="localhost"
port="9999" />
</beans>
已尝试以下多种变体:
xmlstarlet ed -N B="http://www.springframework.org/schema/beans" -N R="http://www.springframework.org/schema/rabbit" --update "/B/R:connection-factor/@host" --value "myserver" dog.xml
我错过了什么?我已经为 B 和 R 的许多变体尝试了 beans 和 B:beans,但我认为没有选择正确的元素。
用你的例子解决 failed to load external entity
问题的两种方法:
xmlstarlet edit --update "//@host" --value "myserver" file.xml
或
xmlstarlet edit --update "//*[local-name()='connection-factory']/@host" --value "myserver" file.xml
具有完整的命名空间声明,
xmlstarlet ed \
-N B="http://www.springframework.org/schema/beans" \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/B:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
或者,使用 xmlstarlet
快捷方式,根据
user guide:
xmlstarlet ed \
-N rabbit="http://www.springframework.org/schema/rabbit" \
--update '/_:beans/rabbit:connection-factory/@host' \
--value "myserver" dog.xml
找出拼写错误:您的命令丢失
connection-factory
.
y