I have a python script that parses an XML file and executes commands. I want my xml read another XML file and edit it. For this, I used the perl command
"perl -pi -0777 -e ' s@ <en:TagName>.*?</en:TagName>@<en:TagName>new-value</en:TagName>@sg'FileName.xml"
I added this to my XML file, which is analyzed by the shell script.
<cmd>perl -pi -0777 -e ' s@ <en:TagName>.*?</en:TagName>@<en:TagName>new-value</en:TagName>@sg'FileName.xml</cmd>
here my python script processes <en:TagName> as a tag and cannot <en:TagName> it. So I added "perl -pi -0777 -e 's#<en:TagName>.*?<en:TagName>#<en:tagName>new-value</en:TagName>#sg' FileName.xml" , and also used" # "as a separator (since @ is a special character in the shell script that we use)
Room # cannot provide the desired result. Instead of replacing it is adding a new value to the end.
source share