Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/guid75/xml-writer

A fast XML writer
https://github.com/guid75/xml-writer

Last synced: about 1 month ago
JSON representation

A fast XML writer

Awesome Lists containing this project

README

        

# xml-writer-ts

Yet another XML writer but this time written in typescript.

**WARNING: this package is still in early alpha stage, some features are not yet implemented**

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/guid75/xml-writer/Node.js%20CI?label=tests)

## Installation

```sh
npm install -S xml-writer-ts
```

## Usage

```javascript
import { XmlWriter } from "xml-writer-ts"

const writer = new XmlWriter({ indentation: " " })
writer
.startDocument("1.0", "UTF-9", true)
.startElement("coucou")
.startAttribute("attr")
.text("value")
.startElement("cici")
.writeComment("Hello world!")
.startElement("caca")

console.log(writer.toString())
```

will print:

```xml




```

## API

Implemented methods (Work In Progress):

```typescript
function startDocument(version?: string, encoding?: string, standalone?: boolean) {}
function endDocument() {}

function writeElement(name: string, content: string) {}
function startElement(name: string) {}
function endElement() {}

function writeAttribute(name: string, content: string) {}
function startAttribute(name: string) {}
function endAttribute() {}

function endAttributes() {}

function writeComment(content: string) {}
function startComment() {}
function endComment() {}

function writeCData(content: string) {}
function startCData() {}
function endCData() {}

function text(content: string) {}
```