-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to extract Attribute Value w/ Path #51
Comments
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. |
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! |
Without having given this a whole lot of thought, my first inclination would be to add 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. |
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. |
Closing this issue since there has been no update for several months. Feel free to reopen if you decide to further pursue this. |
Consider the following document partial (source: https://community.cablelabs.com/wiki/plugins/servlet/cablelabs/alfresco/download?id=8f900e8b-d1eb-4834-bd26-f04bd623c3d2 , Appendix I.1)
While i can use a Path like
//AMS[@Asset_Class='package']/../App_Data[@Name='Provider_Content_Tier']
to get to a desired Element, I am not able to perform an xpath-style path search to extract just the data in the Value attribute for the identified elements as a []string. Most other XPath implementations support a path such as//AMS[@Asset_Class='package']/../App_Data[@Name='Provider_Content_Tier']/@Value
to extract attribute values directly from the Path.This would be a really great feature to have to allow us to port a legacy app over to Go, without having to refactor our existing paths that perform the attribute extractions.
I'll take a stab at implementing in the coming days.
The text was updated successfully, but these errors were encountered: