Saturday, 15 January 2011

perl - find and replace in xml file -



perl - find and replace in xml file -

i want replace specific value in xml file.

my test xml below -

<field name="abc" isarray="false" islocked="false"> <description>this 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 alter value true false propertyname=abc

any suggestions? sed/awk/perl do.

you through awk,

awk '/propertyname=\"abc\"/{print; getline; sub(/true/,"false")}1' file

xml perl awk sed

No comments:

Post a Comment