Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
utilities for parsing and working with jsonml in array form
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

logo Jsxml

JavaScript utilities for parsing and working xml, mainly in jsonml in array form.

More info on JsonML at jsonml.org and wikipedia

This module implements the following functions:

  • jsxml.fromXml(xml_string) converts a string containing xml to jsonml in array form
  • jsxml.toXml(jsxml_array) converts jsonml in array form to xml
  • jsxml.toObject(jsxml_array) converts jsonml in array form to an easier subscriptable object
  • jsxml.childReduce(jsxml_array, callback_function(accumulator, child_element), initial_value) applies the callback function to each child element of the jsonml array
  • jsxml.getAttr(jsxml_array, attribute) retrieves the value of a given attribute of the jsonml array or undefined if no attributes, or no attributes defined

Released under open source / MIT license

Install

npm install jsxml

Example

node
> var jsxml = require('jsxml');
> 
> // get jsonml value 
> // (note: fromXml returns an array of parse fragments.)
> console.log(jsxml.fromXml('<foo>bar</foo>')[0])
[ 'foo', 'bar' ]

> // get xml value
> console.log(jsxml.toXml(['foo', 'bar']))
<foo>bar</foo>
Something went wrong with that request. Please try again.