Skip to content

Commit

Permalink
Markdown README fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
setnicka committed Aug 21, 2019
1 parent 6f6cc23 commit 11dfa47
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## xml stream parser
# xml stream parser

xml-stream-parser is xml parser for GO. It is efficient to parse large xml data with streaming fashion.

### Usage
## Usage

```xml
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -29,10 +30,9 @@ xml-stream-parser is xml parser for GO. It is efficient to parse large xml data
</bookstore>
```

<b>Stream</b> over books and journals
```go

**Stream** over books and journals

```go
f, _ := os.Open("input.xml")
br := bufio.NewReaderSize(f,65536)
parser := xmlparser.NewXMLParser(br, "book", "journal")
Expand All @@ -44,30 +44,29 @@ for xml := range parser.Stream() {
fmt.Println(xml.Childs["comments"][0].Childs["userComment"][0].InnerText)
}
}

```

<b>Skip</b> tags for speed
**Skip** tags for speed

```go
parser := xmlparser.NewXMLParser(br, "book").SkipElements([]string{"price", "comments"})
```

<b>Error</b> handlings
**Error** handlings

```go
for xml := range parser.Stream() {
if xml.Err !=nil {
if xml.Err !=nil {
// handle error
}
}
```

<b>Progress</b> of parsing
**Progress** of parsing

```go
// total byte read to calculate the progress of parsing
parser.TotalReadSize
```




If you interested check also [json parser](https://github.com/tamerh/jsparser) which works similarly

0 comments on commit 11dfa47

Please sign in to comment.