Created
March 10, 2011 07:24
-
-
Save osima/863701 to your computer and use it in GitHub Desktop.
how to get processingInstruction using jdom.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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