Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Created May 15, 2013 16:47
Show Gist options
  • Save tpolecat/5585398 to your computer and use it in GitHub Desktop.
Save tpolecat/5585398 to your computer and use it in GitHub Desktop.
scala> :pa
// Entering paste mode (ctrl-D to finish)
def stripNamespaces(node : Node) : Node = {
node match {
case e : Elem =>
e.copy(scope = TopScope, child = e.child map (stripNamespaces))
case _ => node;
}
}
<s:test xmlns:s="test">
<s:body xmlns:t="cat">
<cat>
<testtest></testtest>
</cat>
</s:body>
</s:test>
// Exiting paste mode, now interpreting.
stripNamespaces: (node: scala.xml.Node)scala.xml.Node
res24: scala.xml.Elem =
<s:test xmlns:s="test">
<s:body xmlns:t="cat">
<cat>
<testtest></testtest>
</cat>
</s:body>
</s:test>
scala> stripNamespaces(res24)
res25: scala.xml.Node =
<s:test>
<s:body>
<cat>
<testtest></testtest>
</cat>
</s:body>
</s:test>
scala>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment