Skip to content

Commit 23f40b1

Browse files
committed
Update README
1 parent df3ff12 commit 23f40b1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Some of the package's capabilities and features:
2020
* Built on top of the go [encoding/xml](http://golang.org/pkg/encoding/xml)
2121
package.
2222

23+
The etree package is compatible with go versions 1.23 and later.
24+
2325
### Creating an XML document
2426

2527
The following example creates an XML document from scratch using the etree
@@ -114,7 +116,7 @@ etree selection queries.
114116
root := doc.SelectElement("bookstore")
115117
fmt.Println("ROOT element:", root.Tag)
116118

117-
for _, book := range root.SelectElements("book") {
119+
for _, book := range root.SelectElementsSeq("book") {
118120
fmt.Println("CHILD element:", book.Tag)
119121
if title := book.SelectElement("title"); title != nil {
120122
lang := title.SelectAttrValue("lang", "unknown")
@@ -149,7 +151,7 @@ into the category of 'WEB'. The double-slash prefix in the path causes the
149151
search for book elements to occur recursively; book elements may appear at any
150152
level of the XML hierarchy.
151153
```go
152-
for _, t := range doc.FindElements("//book[@category='WEB']/title") {
154+
for _, t := range doc.FindElementsSeq("//book[@category='WEB']/title") {
153155
fmt.Println("Title:", t.Text())
154156
}
155157
```
@@ -163,7 +165,7 @@ Title: Learning XML
163165
This example finds the first book element under the root bookstore element and
164166
outputs the tag and text of each of its child elements.
165167
```go
166-
for _, e := range doc.FindElements("./bookstore/book[1]/*") {
168+
for _, e := range doc.FindElementsSeq("./bookstore/book[1]/*") {
167169
fmt.Printf("%s: %s\n", e.Tag, e.Text())
168170
}
169171
```
@@ -179,7 +181,7 @@ price: 30.00
179181
This example finds all books with a price of 49.99 and outputs their titles.
180182
```go
181183
path := etree.MustCompilePath("./bookstore/book[p:price='49.99']/title")
182-
for _, e := range doc.FindElementsPath(path) {
184+
for _, e := range doc.FindElementsPathSeq(path) {
183185
fmt.Println(e.Text())
184186
}
185187
```
@@ -189,8 +191,8 @@ Output:
189191
XQuery Kick Start
190192
```
191193

192-
Note that this example uses the FindElementsPath function, which takes as an
193-
argument a pre-compiled path object. Use precompiled paths when you plan to
194+
Note that this example uses the `FindElementsPathSeq` function, which takes as
195+
an argument a pre-compiled path object. Use precompiled paths when you plan to
194196
search with the same path more than once.
195197

196198
### Other features

0 commit comments

Comments
 (0)