1

I am unable to update following xml file due to tag attribute, xmlns (namespace)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<advertiserFeatures
xmlns:doc="http://api.homeaway.com/service/v1"
xmlns="http://api.homeaway.com/domain/v0" etag="33054400302" url="/advertisers/0024/e74510aa-d4f0-4509-8c48-7c101e6f021c/features">
<parentEntity href="/advertisers/0024/e74510aa-d4f0-4509-8c48-7c101e6f021c" rel="parentEntity"/>
<advertiseVasCart>true</advertiseVasCart>
<agentAssistedCheckout>true</agentAssistedCheckout>
<dcfEnabled>false</dcfEnabled>
<enhancedDistribution>false</enhancedDistribution>
<inserted>2016-02-12T15:38:58.977Z</inserted>
<travelerFeeEnabled>true</travelerFeeEnabled>
<updated>2016-02-12T15:38:58.977Z</updated>

I can update with following command if I remove that attribute

xmlstarlet ed -u "/advertiserFeatures/advertiseVasCart" -v "false" advertiserFeatures.xml > advertiserFeatures1.xml

Any idea what am I missing?

1 Answer 1

1

You need to bind a prefix to the default namespace URI, and then use that prefix in your XPath to address elements in the corresponding namespace :

xmlstarlet ed -N x="http://api.homeaway.com/domain/v0" \
    -u "/x:advertiserFeatures/x:advertiseVasCart" \
    -v "false" advertiserFeatures.xml > advertiserFeatures1.xml

For further reading : xmlstarlet documentation on 'Namespaces and default namespace'

Sign up to request clarification or add additional context in comments.

Comments

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.