import os, sys
import xml.dom.minidom
f=file(sys.argv[1])
result = file(sys.argv[2],"w")
doc = xml.dom.minidom.Document()
root=doc.createElementNS("", "someURIs")
doc.appendChild(doc.createProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" href=\"multiple_input3.xsl\""))
doc.appendChild(root)
# read lines from in file
for line in f.readlines():
node = doc.createElementNS("", "file")
node.appendChild(doc.createTextNode(line))
root.appendChild(node)
# write result
result.write(doc.toprettyxml(indent=" ",encoding="ISO-8859-1"))
|