Xml2Json Class
Defined in:
Module: xml2json
node -> see if https://github.com/isaacs/sax-js could be used instead
packages\node-opcua-xml2json\src\xml2json.js:139
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 = "
parser.parseString(xml_string, function() { parser.obj.should.eql({name: 'John',address: 'Paris'}); done(); });
Item Index
Methods
Methods
parse
(
async
-
xmlFile
-
callback
Parameters:
-
xmlFile
String- the name of the xml file to parse.
-
callback
Function
parseString
(
async
-
xml_text
-
callback
Parameters:
-
xml_text
String- the xml string to parse.
-
callback
Function