Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is giving error while working with keys having : in it #46

Open
shaileshbonzer opened this issue Feb 28, 2022 · 1 comment
Open

It is giving error while working with keys having : in it #46

shaileshbonzer opened this issue Feb 28, 2022 · 1 comment

Comments

@shaileshbonzer
Copy link

I am going to send XML response from my node js api.

When I am sending data like following

res.set('Content-Type', 'text/xml');

let example5 = [
  {
    toys: [
      {
        _attr: {
          decade: '80s',
          locale: 'US'
        }
      },
      {
        toy: 'Transformers'
      },
      {
        toy: [
          {
            _attr: {
              knowing: 'half the battle'
            }
          },
          'GI Joe'
        ]
      },
      {
        toy: [
          {
            name: 'He-man'
          },
          {
            'g:brand': 'He-man'
          },
          {
            description: {
              _cdata: '<strong>Master of the Universe!</strong>'
            }
          }
        ]
      }
    ]
  }
]

return res.send(xml(example5, true));

When using the key with : it is giving error like this
xml_error

@EECOLOR
Copy link

EECOLOR commented Jul 14, 2023

In xml the : marks the use of a namspace, you need to declare the namespace if you want the xml document to be valid. You can find a simple example here: https://www.w3schools.com/xml/xml_namespaces.asp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants