Skip to content

Instantly share code, notes, and snippets.

@russellkt
Created December 21, 2011 17:17
Show Gist options
  • Save russellkt/1506835 to your computer and use it in GitHub Desktop.
Save russellkt/1506835 to your computer and use it in GitHub Desktop.
def xmlFilePattern = ~/.*\.XML/
def iterator = 0
def itemAttributes, contentAttributes
def checkAttributes = []
def checks = []
new File('/Volumes/mac3/cleared_checks/').eachFileMatch(xmlFilePattern){
def xmlFile = new XmlParser().parse(it)
def items = xmlFile.Item
if(itemAttributes == null){
itemAttributes = items.ItemData[0].attributes().keySet()
contentAttributes = items.Content[0].attributes().keySet()
checkAttributes = new String[itemAttributes.size() + contentAttributes.size()]
itemAttributes.eachWithIndex{ att, index -> checkAttributes[index] = att }
contentAttributes.eachWithIndex{ att, index -> checkAttributes[index + itemAttributes.size()] = att }
}
items.eachWithIndex{ item, index ->
def check = []
itemValues = item.ItemData[0].attributes().collect{ k,v -> v}
contentValues = item.Content[0].attributes().collect{ k,v -> v}
check = itemValues + contentValues
checks << check
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment