Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcdole committed Sep 21, 2020
1 parent 130412e commit 2f3784f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,40 @@

The `goxpp` library is an XML parser library that is loosely based on the [Java XMLPullParser](http://www.xmlpull.org/v1/download/unpacked/doc/quick_intro.html). This library allows you to easily parse arbitrary XML content using a pull parser. You can think of `goxpp` as a lightweight wrapper around Go's XML `Decoder` that provides a set of functions that make it easier to parse XML content than using the raw decoder itself.

## Overview

To begin parsing a XML document using `goxpp` you must pass it an `io.Reader` object for your document:

```go
file, err := os.Open("path/file.xml")
parser := xpp.NewXMLPullParser(file, false, charset.NewReader)
```

The `goxpp` library decodes documents into a series of token objects:

| Token Name |
|----------------------------------|
| StartDocument |
| EndDocument |
| StartTag |
| EndTag |
| Text |
| Comment |
| ProcessingInstruction |
| Directive |
| IgnorableWhitespace |

You will always start at the `StartDocument` token and can use the following functions to walk through a document:

| Function Name | Description |
|----------------------------------|---------------------------------------|
| Next() | Advance to the next `Text`, `StartTag`, `EndTag`, `EndDocument` token.<br>Note: skips `Comment`, `Directive` and `ProcessingInstruction` |
| NextToken() | Advance to the next token regardless of type. |
| NextText() | Advance to the next `Text` token. |
| Skip() | Skip the next token. |
| DecodeElement(v interface{}) | Decode an entire element from the current tag into a struct.<br>Note: must be at a `StartTag` token |



This project is licensed under the [MIT License](https://raw.githubusercontent.com/mmcdole/goxpp/master/LICENSE)

0 comments on commit 2f3784f

Please sign in to comment.