Skip to content

Instantly share code, notes, and snippets.

@osima
Created March 10, 2011 07:24
Show Gist options
  • Select an option

  • Save osima/863701 to your computer and use it in GitHub Desktop.

Select an option

Save osima/863701 to your computer and use it in GitHub Desktop.
how to get processingInstruction using jdom.
@Grab(group='jdom', module='jdom', version='1.1')
import org.jdom.*
import org.jdom.input.*
xmldata='''<?xml version="1.0"?>
<?xml-stylesheet href="style.xsl" type="text/xsl"?>
<html>
<body>
<h1>hello jdom</h1>
</body>
</html>
'''
recur = { def obj , int indent ->
println ' '*indent + obj.toString().replaceAll('\n','')
if( obj instanceof Parent ){
obj.content.each{
recur(it , indent+1 )
}
}
}
def doc = new SAXBuilder().build( new StringReader(xmldata) )
recur(doc,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment