Skip to content

Instantly share code, notes, and snippets.

@nhajratw
Created March 12, 2012 16:29
Show Gist options
  • Save nhajratw/2023178 to your computer and use it in GitHub Desktop.
Save nhajratw/2023178 to your computer and use it in GitHub Desktop.
<root>
<a>
<b>123</b>
<b>456</b>
<b>789</b>
</a>
<a>
<b>foo</b>
</b>bar</b>
</a>
</root>
I want to end up with
{[
a: [ b: 123, b: 456, b: 789],
a: [ b: foo, b: bar ]
]}
or something approximately similar.
@dnewcome
Copy link

I'm a little confused at your proposed output. It looks like you're going for an array of arrays maybe since it doesn't make sense to have a hash of values having the same key.

You could try this:

template = [ '//a', [ 'b', 'text()' ] ];

Output:

[
    ["123","456","789"],
    ["foo","bar"]
]

@nhajratw
Copy link
Author

Thanks for the response. I actually don't remember why I wanted this any longer. I know we're continuing to use Jath and it seems to be working fine. It's possible I didn't know what I was doing when I proposed this. :-)

I'll definitely keep your proposal in mind, should I discover a need for it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment