I am trying to edit android manifest file with xmlstarlet. I want to change package attribute node.
Input file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.demoapp">
</manifest>
expected output:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prod.demoapp">
</manifest>
I tried few things, I think it's a issue with namespace. I am unable to select package attribute since it's value package name(e.g. com.test.demoapp) is a variable.
xmlstarlet edit -N N="http://schemas.android.com/apk/res/android" \
--update "//N:manifest[@name='package']/@value" \
--value "com.prod.demoapp" $androidManifestXMLfile
I also tried without namespace
xmlstarlet edit \
--update "//manifest[@name='package']/@value" \
--value "test" $androidManifestXMLfile
But in both cases nothing is changed. Output is content of xml file.
Your selection of a manifest
tag with attribute name='package'
does not match anything.
Instead just select the package
attribute itself like this:
xmlstarlet edit \
--update "//manifest/@package" \
--value "com.prod.demoapp" $androidManifestXMLfile