Comments (5)
One thing to keep in mind is that, unlike XPath, the etree Path library returns Element pointers instead of strings. This might make it tricky to support XPath-like queries that return attributes, since Attributes are a whole separate type in etree.
from etree.
Yeah, my initial thinking was providing a new function like GetAttribute() that accepts the Path and returns []string. Do you have any thoughts on that? Thanks for getting back to me!
from etree.
Without having given this a whole lot of thought, my first inclination would be to add FindAttribute
and FindAttributes
methods that return Attr
pointers. This would keep them similar to FindElement
and FindElements
. But I'm not sure that would be very useful, since the Attr
instances do not maintain any information about the element they belong to (unlike the Element
instances, which know their children and parents).
What you're asking for is basically a new kind of path system that works more like XPath and less like etree Paths. Basically, you're looking for something that returns strings. Normally when people ask for this, I refer them to the xmlpath package. etree has never attempted to provide a compliant XPath implementation. The path system used by etree is more similar to the python etree module upon which I modeled it.
from etree.
Oh, one other thing. I'm going to be replacing the current etree path implementation with the code in pull request #50. I still need to optimize it, so I'm not ready to commit it yet. But if you're going to do any work on paths, you'd probably want to start there.
from etree.
Closing this issue since there has been no update for several months. Feel free to reopen if you decide to further pursue this.
from etree.
Related Issues (20)
- RFE: Add round-trip checking HOT 5
- function AddChild bug? HOT 1
- Can you share performance benchmarks or steps to measure it for this tool? HOT 2
- Perhaps link prominently to docs? HOT 1
- Add doctype read HOT 1
- a bug of Element.Text() HOT 1
- Error Read xml ISO-8859-1 HOT 1
- can not parse xml with "&" HOT 1
- Unexpected <></> when adding outer layer HOT 3
- Expected " but " HOT 1
- go version EOL HOT 1
- how to pretty print when writing back HOT 4
- xml writeto string? HOT 1
- UTF-8 support HOT 3
- Does this library supports XInclude standards for XML document? HOT 1
- How do I remove indent between inline labels? HOT 2
- Is there any way to get the comments of a document? HOT 5
- i don't wanna the string text to be escaped, how can i achieve that HOT 5
- if my text contains some string likes '<br>',but i dont wanna to escape them,how can i do HOT 2
- XPath string literal syntax does not accept double quotes HOT 2
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 etree.