Skip to content

Routes: XML Parser

TekMonks edited this page Mar 14, 2019 · 2 revisions

The XML Parser Route

The XML Parser route node is used to parse an XML document into a JSON document. ASB uses the fast-xml-parser for this, which is the one of the fastest JS XML parsers.

The XML parser will ensure the incoming document is syntactically correct, and then produce a corresponding JSON tree. To find out the output JSON tree format, please refer to the documentation for fast-xml-parser here

The code block below documents the format for the XML Parser route node.

"route1": {
	"type":"xmlparser",
	"dependencies":["route0"]
}

There are no properties to configure, but the message.content of the incoming message must be in XML.

The code block below illustrates a pipeline to transform an XML file to a JSON file.

{
	"flow":{
		"name":"XML to JSON",
		"disabled":true
	},
	"listener": {
		"type":"file", 
		"isMessageGenerator": true,
		"path":"c:/test/in/Test.xml",
		"donePath":"c:/test/processing"
	},
	"route0":{
		"type": "filereader",
		"dependencies":["listener"],
		"donePath":"c:/test/done",
		"encoding":"utf8"
	},
	"route1": {
		"type":"xmlparser",
		"dependencies":["route0"]
	},
	"output": {
		"type": "filewriter",
		"dependencies":"route1",
		"path":"c:/test/Test.json",
		"prettyJSON": 4,
		"append": false,
		"writeCloseTimeout": 5000
	}
}