Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-xml-ls

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-xml-ls

Another JS object to XML converter

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

create-xml-ls Build Status

Another JS object to XML converter

Instalation

npm install create-xml-ls

Example

Javascript

createXml(obj[, options])
var createXml = require('create-xml-ls');

createXml({
  something: {
    is: 'very',
    ugly: {
      $attr: {
        IMHO: 'it sucks'
      }
      but: 'sometimes we have to live with it'
    }
  }
}, { pretty: true });
/* =>
<?xml version="1.0" encoding="UTF-8"?>
<something>
  <is>very</is>
  <ugly IMHO="it sucks">
    <but>sometimes we have to live with it</but>
  </ugly>
</something>
*/

Indentation is off by default, but can be toggled with options.pretty set to true.

The default attributes key is '$attr', but you can also use a custom one by setting options.attributesKey to the desired key.

createXml({
  something:
    is: {
      attributes: {
        'kind': 'of'
      },
      interesting: 'about this'
    }
}, { pretty: true, attributesKey: 'attributes' );
/* =>
<?xml version="1.0" encoding="UTF-8"?>
<something>
  <is kind="of">
    <interesting>about this</interesting>
  </is>
</something>
*/

There's also support for array properties.

createXml({
  arrayExample: {
    sometimes: [
      'I',
      'had',
      'to',
      'do',
      'this'
    ]
  }
}, { pretty: true });
/* =>
<?xml version="1.0" encoding="UTF-8"?>
<arrayExample>
  <sometimes>I</sometimes>
  <sometimes>had</sometimes>
  <sometimes>to</sometimes>
  <sometimes>do</sometimes>
  <sometimes>this</sometimes>
</arrayExample>
*/}

License

Copyright (c) 2013 Pedro Yamada. Licensed under the MIT license.

FAQs

Package last updated on 25 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc