Skip to content

Instantly share code, notes, and snippets.

@dodok1
Last active February 19, 2018 19:02
Show Gist options
  • Save dodok1/4352500 to your computer and use it in GitHub Desktop.
Save dodok1/4352500 to your computer and use it in GitHub Desktop.
prototype for confluence content parsing # Get Confluence XML Schema # Put confluence.dtd and xhtml-*.ent to your working directory # Try attached groovy script
import groovy.xml.XmlUtil
def content=new File(args[0]).getText()
def slurper = new XmlSlurper(false,false)
def prefix = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ac:confluence SYSTEM "confluence.dtd">
<ac:confluence xmlns:ac="http://www.atlassian.com/schema/confluence/4/ac/" xmlns:ri="http://www.atlassian.com/schema/confluence/4/ri/" xmlns="http://www.atlassian.com/schema/confluence/4/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atlassian.com/schema/confluence/4/ac/ confluence.xsd">
"""
def suffix = "</ac:confluence>"
def xml = slurper.parseText(prefix+content+suffix)
println XmlUtil.serialize(xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment