API Docs for: 0.0.57
Show:

Xml2Json Class

Constructor

Xml2Json

(
  • options
)

Parameters:

  • options ReaderState
    • the state machine as a ReaderState node.
    • [parser=null] ReaderState optional
    • [init|null] Function optional
    • [finish] Function optional
    • [startElement] Function optional
    • [endElement] Function optional

Example:

var parser = new Xml2Json({ parser: { 'person': { init: function(name,attrs) { this.parent.root.obj = {}; this.obj = this.parent.root.obj; this.obj['name'] = attrs['name']; }, parser: { 'address': { finish: function(){ this.parent.obj['address'] = this.text; } } } } } });

var xml_string = "" + " " + "

Paris
" + " " + "";

parser.parseString(xml_string, function() { parser.obj.should.eql({name: 'John',address: 'Paris'}); done(); });

Item Index

Methods

Methods

parse

(
  • xmlFile
  • callback
)
async

Parameters:

  • xmlFile String
    • the name of the xml file to parse.
  • callback Callback

parseString

(
  • xml_text
  • callback
)
async

Parameters:

  • xml_text String
    • the xml string to parse.
  • callback Callback