0

This is my XML file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.abc.def" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>JoinTMA</name>
</widget>

I want to update the value of version="1.0.0" to version="2.0.0"

I tried with the following command on macOS

xml ed -N x="http://www.w3.org/ns/widgets" -u "/widget[@version='1.0.0']/@version" -v "2.0.0" fileName

But it did not update the version number

1 Answer 1

3

Notice that your XML has default namespace :

xmlns="http://www.w3.org/ns/widgets"

Therefore, widget and name elements are implicitly in that namespace. You have declared prefix x mapped to the default namespace URI, so you only need to use that prefix to reference widget in your XPath :

xml ed -N x="http://www.w3.org/ns/widgets" -u "/x:widget[@version='1.0.0']/@version" -v "2.0.0" fileName
                                                ^use the prefix
Sign up to request clarification or add additional context in comments.

1 Comment

I just used "//x:widget[@version='1.0.0']/@version" in stead of "/x:widget[@version='1.0.0']/@version" and its working fine now. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.