Skip to content

Commit deb27cf

Browse files
committed
Merge PR #132
2 parents fd6d54d + 9769867 commit deb27cf

File tree

4 files changed

+431
-14
lines changed

4 files changed

+431
-14
lines changed

node.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ type Node struct {
5050
NamespaceURI string
5151
Attr []Attr
5252

53-
level int // node level in the tree
53+
level int // node level in the tree
54+
LineNumber int // line number where this node appears in the source XML
5455
}
5556

5657
type outputConfiguration struct {
@@ -122,6 +123,11 @@ func (n *Node) Level() int {
122123
return n.level
123124
}
124125

126+
// GetLineNumber returns the line number where this node appears in the source XML.
127+
func (n *Node) GetLineNumber() int {
128+
return n.LineNumber
129+
}
130+
125131
// InnerText returns the text between the start and end tags of the object.
126132
func (n *Node) InnerText() string {
127133
var output func(*strings.Builder, *Node)

options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
)
77

88
type ParserOptions struct {
9-
Decoder *DecoderOptions
9+
Decoder *DecoderOptions
10+
WithLineNumbers bool
1011
}
1112

1213
func (options ParserOptions) apply(parser *parser) {

0 commit comments

Comments
 (0)