Skip to content

Commit

Permalink
fix docs and example
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Banning committed Feb 22, 2017
1 parent a3b6231 commit 2748c50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 2 additions & 6 deletions examples/leafnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package main

import (
"fmt"
"strings"

"github.com/clbanning/mxj"
)
Expand Down Expand Up @@ -46,13 +45,10 @@ func main() {
fmt.Println("err:", err)
return
}
mxj.LeafUseDotNotation()
l := m.LeafNodes()

// now change the [n] to .n
for _, v := range l {
p := strings.Replace(v.Path, "[", ".", -1)
p = strings.Replace(p, "]", "", -1)
fmt.Println("path:", p, "value:", v.Value)
fmt.Println("path:", v.Path, "value:", v.Value)
}
/*
Output (sequence not guaranteed):
Expand Down
10 changes: 7 additions & 3 deletions leafnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ type LeafNode struct {
// LeafNodes - returns an array of all LeafNode values for the Map.
// The option no_attr argument suppresses attribute values (keys with prepended hyphen, '-')
// as well as the "#text" key for the associated simple element value.
// NOTE: if PrependAttrWithHypen(false), then #test is stripping "#text" key
// will result in attributes having .attr-name as terminal node in 'path' while
// the path for the element value, itself, will be the base path w/o "#text".
//
// PrependAttrWithHypen(false) will result in attributes having .attr-name as
// terminal node in 'path' while the path for the element value, itself, will be
// the base path w/o "#text".
//
// LeafUseDotNotation(true) causes list members to be identified using ".N" syntax
// rather than "[N]" syntax.
func (mv Map) LeafNodes(no_attr ...bool) []LeafNode {
var a bool
if len(no_attr) == 1 {
Expand Down

0 comments on commit 2748c50

Please sign in to comment.