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

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

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.