JS-PARSE-XML Demo

node v14.20.1
version: 1.0.0
endpointsharetweet
// simple demo using synchronous string parsing // import everything available from js-parse-xml /* Available options: { encoding: "utf-8", stream: false, preserve_whitespace: false, convert_values: true, strict: true } */ let {Parser, parseString, parseFile, parseStringSync, parseFileSync } = require("js-parse-xml") let json /**************************************************************\ This shows the easiest and most common way to parse XML \**************************************************************/ json = parseStringSync("<root>Example</root>") // print it out console.log(json) /**************************************************************\ This shows how to use the Parser class \**************************************************************/ let parser = new Parser({strict:false}) // feed is stream based, so does not matter where lines are cut off parser.feed("<roo") parser.feed("t>Exam") parser.feed("ple</root>") json = parser.finish() // get the parsed object // print out the json console.log(json)
Loading…

no comments

    sign in to comment