Home > Net >  node xml package not working with keys having : in it
node xml package not working with keys having : in it

Time:03-01

I am going to send XML response from my node js api. Currently I am using xml - npm enter image description here

CodePudding user response:

Colon in the tag means namespace prefix, and because you're missing a g: namespace, it's rather not a valid XML, than a node-xml problem.

you need to define namespace, looks like Google Merchant, so try adding it in the root's _attr like this:

 {
    toys: [
      {
        _attr: {
          decade: '80s',
          locale: 'US',   
          "xmlns:g": "http://base.google.com/ns/1.0"
          //...

check: What does the XML syntax with a colon mean?

  • Related