Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joafalves/javascript-xml-builder-web
JavaScript Xml Builder
https://github.com/joafalves/javascript-xml-builder-web
Last synced: 10 days ago
JSON representation
JavaScript Xml Builder
- Host: GitHub
- URL: https://github.com/joafalves/javascript-xml-builder-web
- Owner: joafalves
- License: mit
- Created: 2015-10-06T10:06:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-12T09:20:36.000Z (about 9 years ago)
- Last Synced: 2023-08-06T16:56:27.937Z (over 1 year ago)
- Language: JavaScript
- Size: 168 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JavaScript-Xml-Builder-Web
Simple Javascript Class Builder for the web!# How to use:
- Import the xmlbuilder.js file in your HTML page.
- It's ready!# Example:
```javascriptvar builder = new XmlBuilder();
var xmlStr = builder.create("master", {"xmlns": "bx:mpa", "xmlns:url": "url"}, "")
.elem("slave", "", {"attrib": "myValue"})
.elem("url:inner", "myValueA") // add an element
.if(0>1).parent().elem("inner", "myValueB").endif() // 0 > 1 condition = sample, this won't be added
.parent().elem("inner", "myValueC")
.flush() // resets parenting logic
.elem("slave", "", {"attrib": "myValue"})
.flush()
.toString();console.log(xmlStr);
```
Will generate:
```xml
myValueA
myValueC
```