Reputation: 111
I'm running command:
cat ./xml | virt-xml --edit --xml ./tag1/tag2="a=b" > output.xml
it should add text a=b in tag2 but it is creating <tag2=a>b</tag2=a> which is incorrect. I tried to escape equal character as well but no success.
How can I achieve this ?
the command I mentioned above should add text a=b in tag2 but it is creating <tag2=a>b</tag2=a> which is incorrect. I tried to escape equal character as well but no success.
Upvotes: 0
Views: 75
Reputation: 181519
I'm running command:
cat ./xml | virt-xml --edit --xml ./tag1/tag2="a=b" > output.xml
it should add text a=b in tag2 but it is creating <tag2=a>b</tag2=a> which is incorrect. I tried to escape equal character as well but no success.
The quotation marks in your command are interpreted by the shell. virt-xml
never sees them. And if it did (for example, if you escaped them from shell interpretation), then I anticipate that it would interpret them as literal characters. Similar applies to escaping one or more of the =
signs.
The docs for virt-xml
's --xml
option are only summarized in that command's own manual page. It refers to the docs for virt-install
for a full explanation, which explains that --xml
has sub-options. You are, by default, using the xpath.set
suboption to specify both node to edit and a value to set, but you can also specify the value to set separately via the xpath.value
suboption. Its docs include:
May help sidestep problems if the string you need to set contains a '=' equals sign.
That's exactly your situation.
I anticipate, then, that you can obtain the result you want with
cat ./xml |
virt-xml --edit --xml xpath.set=./tag1/tag2 xpath.value=a=b \
> output.xml
Or at least, that should resolve the particular you asked in the question.
Upvotes: 0