Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/schizobulia/antlrv4-js-xml
- Owner: schizobulia
- Created: 2022-07-09T14:04:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-09T14:05:19.000Z (over 2 years ago)
- Last Synced: 2024-11-19T15:03:32.881Z (about 2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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('
', new Visitor())
21
```### 浏览器中使用
```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);
}
```