Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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:
```javascript

var 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

```