Search code examples
xmlxmlstarlet

how to change ionic app version using xmlstarlet?


I'm trying to change my ionic app version when i add a new release to my git repo. In order to achieve this I executing xmlstarlet ed -L -u 'widget\@version' -v '<tag value>' config.xml but the output came with nothing changed. I have already tried the xpath expression and it find the node. this is 'config.xml' file:

<?xml version="1.0"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" id="io.ionic.my_app" version="1.0.3">
...
</widget>

If I remove the properties xmlns and xmlns:cdv it works, why those properties affects how xmlstarlet works and how can I fix this?


Solution

  • Well, this problem happens because of the use of namespaces. It can be fixed by adding a namespace property to xmlstarlet using option -N the command would get like this

    xmlstarlet ed -L -N N='http://www.w3.org/ns/widgets' -u 'N:widget/@version' -v '1.0.10' config.xml
    

    As you can see we add N: to the xpath