There is the following config.xml file (the file is from a source repository what I cannot change in an automated process; I can change the build process though so ideas on how to extract two properties, the androidversionCode and the iosCFBundleVersion would be appreciated.
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.company.project" version="1.2.8" androidversionCode="209" iosCFBundleVersion="209" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Project name</name>
<description>Project description</description>
</widget>
What I try:
$ xmllint --xpath "string(//widget/@id)" config.xml
That only works when xmlns="http://www.w3.org/ns/widgets" is removed from the file. If I set xmlns="" then it works too, but I found no other cases it would be returning id or any version code. So, xmlns="something" makes xpath fail, right?
How can I make this work and fetch those version numbers?
And the resolution is:
xmllint --xpath 'string(//*[local-name()="widget"]/@id)' config.xml