ionic-team / trapeze

The mobile project configuration toolbox. Manage native iOS, Android, Ionic/Capacitor, React Native, and Flutter apps through a simple YAML format.
https://trapeze.dev
Other
315 stars 39 forks source link

XML file namespace #190

Open agoncalvesos opened 1 year ago

agoncalvesos commented 1 year ago

Hey!

I'm experiencing an issue when trying to inject/delete/merge text in an XML file (the cordova config.xml file). Here's my trapeze-conf file:

  xml:
    - file: config.xml
      target: widget
      delete: /widget/allow-navigation[@href='https://*/*']
    - file: config.xml
      target: widget
      inject: |
        <allow-intent href="https://*/*" />

And here is a sample of my config.xml file:

    android-versionCode="11"
    id="my-application.id"
    ios-CFBundleVersion="1.0"
    version="0.1"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <allow-navigation href="https://*/*" />
</widget>

If I remove the xmlns="http://www.w3.org/ns/widgets" it works as expected! Any idea why?

Using v7.0.10.

Thanks!

agoncalvesos commented 1 year ago

Related to https://github.com/goto100/xpath/issues/36

mlynch commented 1 year ago

Can you try

target: //*[local-name() = 'widget']
mherbertecifm commented 7 months ago

I'm facing a similar issue trying to update the "version" attribute in config.xml. currently using this, but it's not working...

project:
  xml:
    - file: config.xml
      target: widget
      attrs:
        version: "7.8.9"

@mlynch I tried your suggestion above but it didn't work :(