[英]find and replace in xml file
I want to replace a specific value in xml file. 我想替换xml文件中的特定值。
My Test XML is as below - 我的测试XML如下-
<Field Name="ABC" IsArray="false" IsLocked="false">
<Description>THIS IS FOR ABC VALUE</Description>
<Comment></Comment>
<PropertyList>
<Property Name="ABC" Type="Boolean">
<DefaultValue>false</DefaultValue>
</Property>
</PropertyList>
<PropertyValueList>
<PropertyValue PropertyName="ABC">
<Value>true</Value>
</PropertyValue>
</PropertyValueList>
</Field>
I want to change value from true to false only for PropertyName=ABC
我只想将
PropertyName=ABC
值从true更改为false
Any suggestions? 有什么建议么? sed/awk/perl anything would do.
sed / awk / perl什么都可以做。
您可以通过awk做到这一点,
awk '/PropertyName=\"ABC\"/{print; getline; sub(/true/,"false")}1' file
您可以使用xmlstarlet :
xmlstarlet ed -u "/Field/PropertyValueList/PropertyValue/Value/text()" -v "false" test.xml > result.xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.