June 10th, 2004, 03:27 AM
You cannot just concatenate XML files and expect the result to be valid XML. A valid XML file has one and only one root node, and everything else must be within that root. If you concatenate two or more XML files then you will have more than one root. You also only want the file metadata appearing at the head of the file, not repeated in the middle.
You could have your files containing snippets of XML, and insert them into the root element, something like this:
#untested code - caveat emptor
xmlRoot = '''
files = [ 'file1.xml', 'file2.xml', 'file3.xml' ]
xmlTexts = [ open(file, 'r').read() for file in files ]
xml = xmlRoot % ''.join(xmlTexts)
This will produce syntactically correct XML, but it may or may not be semantically correct since the ordering of nodes may be significant.
Dave - The Developers' Coach