https://github.com/vgratian/shallowxml
shallow XML parser
https://github.com/vgratian/shallowxml
xml xml-parser
Last synced: 6 months ago
JSON representation
shallow XML parser
- Host: GitHub
- URL: https://github.com/vgratian/shallowxml
- Owner: vgratian
- Created: 2020-11-01T20:59:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-01T22:09:53.000Z (over 5 years ago)
- Last Synced: 2024-06-19T05:27:38.000Z (about 2 years ago)
- Topics: xml, xml-parser
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## shallowXML
A simple XML parser that first creates a Root element and then adds child elements. I started learning Go only yesteray, so I couldn't really do everything the way I wanted (e.g. I did't konw how to declare methods, so I used functions instead).
The end-goal is to write a parser that is linear in time to the size of the input string and also stores nothing more than that one string in memory (the way I'll do it is to store the string in the root element and use pointers in all of it's children.).
The goal is also to have API similiar to that of [lxml](https://lxml.de/) / [elementree](http://effbot.org/zone/element.htm).
## How to use
First argument should be path of an XML file, e.g.:
```shell
$ go run parser.go example.xml
```
and output is:
```bash
() 2
| () 3
| | (Jack) 0
| | (McGreen) 0
| |
() 2
| | | (London) 0
| | | (UK) 0
| () 2
| | (Anna) 0
| | (Krikorian) 0
```
## Disclaimer
Of course this is just a toy-project / draft. No checks are done to detect invalid XML syntax, no error handling. XML elements with attributes (e.g. ``) will not be recognized.