-
Notifications
You must be signed in to change notification settings - Fork 125
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
XML Parsing Help #40
Comments
I have the same issue. I don't think you are doing anything wrong. |
Following up on this since I've been tinkering with Nustache, the XML behavior is weak and poorly defined and I'm tinkering with improving it. @seansms is probably never going to read this 3.5 years later, but we'll pretend he will. Remember that, since This works:
Two things were wrong in your example:
This means the contextual object is now "group". If you want the unnamed root of your entire XML snippet so you can reference the root object by name (group, in this case) you just use Otherwise, you should be leaving "group" out of your template and assuming that group is the default context. Second, because couponid is repeated, it's actually a collection of nameless strings. Group isn't the array, couponid is - group effectively has only one child. I know, it's weird. Now, the problem is that nustache xml getters don't support fetching grandchildren of xml objects - they only support either returning Xml Node Lists (which you can only iterate across, not index) or strings. So we can't say group.couponid or couponid.1 to get the first couponid. I've got some PRs planned to fix that. Edit: I'm silly. It takes xpath queries.
|
Sorry for calling the XML behavior weak - it is, at worst, counterintuitive. Xpath queries have as much if not more expressive power as Mustache dot paths. It's very inconsistent to switch to the xpath syntax, but after tinkering for a bit I can see that it works. But it does seem to fail on cdata. |
For some reason, I can't get this test to pass.
Any ideas what I'm doing wrong?
The text was updated successfully, but these errors were encountered: