Comments (3)
You can find all text nodes with "//text()"
.
For example, this:
var html = `<html><body><div>a</div><div>b</div></body></html>`
func run() error {
path, err := xmlpath.Compile("//text()")
if err != nil {
return err
}
root, err := xmlpath.ParseHTML(bytes.NewReader([]byte(html)))
if err != nil {
return err
}
iter := path.Iter(root)
for iter.Next() {
fmt.Println(iter.Node())
}
return nil
}
Outputs:
a
b
from xmlpath.
Thanks Gustavo.
from xmlpath.
Okay. I'm still getting some strange output like script nodes. I have no idea how to filter them out.
from xmlpath.
Related Issues (20)
- Non-strict parser HOT 6
- Infinite recursion with `%#v` formatter
- Equals operator index out of range
- Basic tutorial HOT 1
- v2 parser refers to old code.google.com repo HOT 1
- How do you set the Charset Reader? HOT 2
- Convenience Functions
- How to get matched node names HOT 1
- No error when parsing empty string HOT 1
- No Length Information Available for Iter HOT 1
- root.String() return "empty" string
- Project scope? HOT 2
- please tag and version this project HOT 2
- Support multiple attribute conditions
- ok deleted
- Active maintainer needed
- XPath in iterated sub-nodes HOT 1
- LGPLv3 and static linking HOT 5
- 2022/01/12 17:05:34 xml: unsupported version "1.1"; only version 1.0 is supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmlpath.