Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/schizobulia/antlrv4-js-xml

Parsing xml by antlr
https://github.com/schizobulia/antlrv4-js-xml

Last synced: about 1 month ago
JSON representation

Parsing xml by antlr

Awesome Lists containing this project

README

        

# antlrv4-js-xml

## 使用antlrv4的js api 解析xml

### 快速开始

```javascript
const antlrv4_js_xml = require('antlrv4-js-xml')

class Visitor extends antlrv4_js_xml.Visitor {
visitElement (ctx) {
console.log(ctx.Name()[0].getText())
return this.visitChildren(ctx);
}
}

xmlantlrv4_js_xml.transform('


2

1


', new Visitor())
```

### 浏览器中使用

```html

console.log(antlrv4_js_xml)

```

### 其他模块的支持

- [v] es
- [v] esm
- [v] umd

### API
```javascript
// Visit a parse tree produced by XMLParser#document.
visitDocument(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#prolog.
visitProlog(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#content.
visitContent(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#element.
visitElement(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#reference.
visitReference(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#attribute.
visitAttribute(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#chardata.
visitChardata(ctx) {
return this.visitChildren(ctx);
}

// Visit a parse tree produced by XMLParser#misc.
visitMisc(ctx) {
return this.visitChildren(ctx);
}
```