-
Notifications
You must be signed in to change notification settings - Fork 112
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
Locate and modify #29
Comments
I have posted a new example - https://github.com/clbanning/mxj/blob/master/examples/jpath.go - that demonstrates using this package to perform the JPath use cases in the 2nd reference you provided in issue #28. There are a number of methods that allow changing values in the Map itself:
See some use cases in https://github.com/clbanning/mxj/tree/master/examples - gonuts1a, gonuts10.go, gonuts10seq.go, gonuts11seq.go, and gonuts12seq.go are pertinent. (The last 4 are examples I did based on a gonuts posting you made last year - https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/tf4aDQ1Hn_c. In fact, gonuts11seq.go and gonuts12seq.go are working with XML that is [similar to] that which you reference, above. I think you'll find gonuts12seq.go doing something close to what you describe.) The mxj package originated to decode XML to map[string]interface{} values as is supported by encoding/json stdlib package for generic data extraction. It is not focussed on directly manipulating XML ... only later was encoding map[string]interface{} values to XML added. The following two libs implement XPath in go.
There is a go JPath implementation here: |
Thanks.
Thanks to your goxpath recommendation. |
Related to issue #28, what I am looking forward to in mxj, is able to locate some records according to XPath/JPath or something similar, them modify the located record.
Please take a look at this .xml file for example, I need to, expressed in xpath term,
//Request
nodes; and for each node found,For example, these changes were to change
//Request
's./[ReportingName]
use thebasename
of./[Url]
( and prefix with../TransactionTimer[Name]
as well, but that's a bonus request if it is too difficult at first).The final result is posted here.
How can I do that? Thx.
The text was updated successfully, but these errors were encountered: