xml-string
Utility to create XML strings. Can be used to write any XML based files such as SVG, HTML or GPX.
Install
$ npm install xml-string
Usage
const xml =
.create()
const svg = xml
.child()
Append a child element
const svg = xmlconst g = svg
.attr()
Add attributes
const svg = xmlconst g = svgg
.data()
Add data
const svg = xmlconst g = svggconst text = gtextdata'Hello world'
.outer()
Returns the XML string
const svg = xmlStringconst g = svggconst text = gtextdata'Hello world' console// returns// '<svg><g id="group"><text>Hello world</text></g></svg>'
Aliases
- .child() > .c()
- .attr() > .a()
- .data() > .d()
Example:
const svg = xmlconst g = svggconst text = gtext console// returns// '<svg><g id="group"><text>Hello world</text></g></svg>'