Skip to content

Instantly share code, notes, and snippets.

@rossajmcd
Created February 20, 2012 21:40
Show Gist options
  • Save rossajmcd/1871638 to your computer and use it in GitHub Desktop.
Save rossajmcd/1871638 to your computer and use it in GitHub Desktop.
Successful zipper tree modification
val original =
<parent>
<child>
<something1/>
<element id="foo">
<section>
<replace id="bar"/>
</section>
</element>
<something2/>
</child>
</parent>.convert
val insert =
<replace key="value">
<foo>foo</foo>
<bar>bar</bar>
</replace>.convert
val replace = (original \\ 'replace) filter (item => item.attrs("id").contains("bar"))
replace.updated(0, insert).unselect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment