Well, I appreciate all the responses. However, I didn't want to remove it, I only wanted to detect it and have the user/developer remove it. Here is what I did to detect it.
import re
# The beginning of an XML Declaration to match.
xmlRegex = '(<\\?xml)'
rg = re.compile(xmlRegex, re.IGNORECASE | re.DOTALL)
lineCount = 0
with open("c:\file.xml") as f:
for line in f:
lineCount += 1
match = rg.search(line)
if match:
self.assertTrue(False, logger.failed("An XML Declaration was detected on line: " + str(lineCount) + "."))
else:
pass