1 year ago

#353267

test-img

errorfree

Edit specific object in xml without additional changes in bash

I need edit some value in my xml files. And I use this code:

xmlstarlet ed --inplace -u \
'//some_folder/buildElement[@name="element_name"]/@some_value' \
-v $var_to_change ${PATH}/my_file.xml

And it is working but not like I expected. I mean, my target value is edit correctly, but additional is changed others line f.e. is remove space or added <?xml version="1.0"?>.

Input:
IS: edit element_name value and remove some space in another lines or add tag on 1 line in xml.

Should be:
edit only element_name value

How can I edit only my expected value without any validation of xml or changes in not expected lines?

xml

bash

editing

xmlstarlet

0 Answers

Your Answer

Accepted video resources