Socket
Socket
Sign inDemoInstall

simple-xml

Package Overview
Dependencies
73
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-xml

A naive XML parser and builder based on libxmljs


Version published
Maintainers
1
Weekly downloads
1
decreased by-66.67%

Weekly downloads

Readme

Source

XML

A naive XML parser and builder based on libxmljs implementing the JSON api. This module was created as a simple way to parse and build xml for web services such as SOAP. It supports parsing arrays of elements or attributes, but not both intermingled.

Usage

npm install simple-xml --save

parse(xml string or libxml document)

Parse a string or a libxml document or element into a Plain Old Javascript Object.

var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item><value>Item 1</value></item><item><value>Item 2</value></item><item><value>Item 3</value></item></items>';
var XML = require('simple-xml');
console.log(JSON.stringify( XML.parse(xml) ));

// {"items":{"item":[{"value":"Item 1"},{"value":"Item 2"},{"value":"Item 3"}]}}

var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item>Item 1</item><item>Item 2</item><item>Item 3</item></items>';
console.log(JSON.stringify( XML.parse(xml) ));

// {"items":{"item":["Item 1","Item 2","Item 3"]}}

stringify(object)

Transforms an object into a simple xml string representation.

var obj = {"items":{"item":[{"value":"Item 1"},{"value":"Item 2"},{"value":"Item 3"}]}}
var XML = require('simple-xml');
console.log( XML.stringify(obj) );

// <items><item><value>Item 1</value></item><item><value>Item 2</value></item><item><value>Item 3</value></item></items>

Keywords

FAQs

Last updated on 18 Jun 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc