title: xml.parsers.expat.ExpatError: no element found: line 1, column 0
body: <p>I am a newbie to Python. I am trying to write a script to modify some data in XML files that I need to use for my testing purposes. I did see a few folks ask the same question, but I was not able to figure out from the answers there what I was doing wrong. I appreciate the help. Here is a sample XML that I am picking up to modify. Thanks for the help</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Parent&gt;
    &lt;FlexIDResponseEx xmlns="http://WWW.YYYY.com/SsIkkk"&gt;
      &lt;response&gt;
        &lt;Header&gt;
          &lt;Status&gt;0&lt;/Status&gt;
        &lt;/Header&gt;
        &lt;Result&gt;
          &lt;InputEcho&gt;
            &lt;Name&gt;
              &lt;First&gt;John&lt;/First&gt;
              &lt;Last&gt;Doe&lt;/Last&gt;
            &lt;/Name&gt;
            &lt;Address&gt;
              &lt;StreetAddress1&gt;XX XXX XX XXXXX&lt;/StreetAddress1&gt;
              &lt;City&gt;XXXXXX&lt;/City&gt;
              &lt;State&gt;XX&lt;/State&gt;
              &lt;Zip5&gt;XXXXX&lt;/Zip5&gt;
            &lt;/Address&gt;
            &lt;Age&gt;0&lt;/Age&gt;
            &lt;SSN&gt;XXXXXX&lt;/SSN&gt;
            &lt;HomePhone&gt;XXXXXXXXX&lt;/HomePhone&gt;
          &lt;/InputEcho&gt;
          &lt;UniqueId&gt;XXXXX&lt;/UniqueId&gt;
          &lt;NameAddressPhone&gt;
            &lt;Summary&gt;1&lt;/Summary&gt;
            &lt;Type&gt;P&lt;/Type&gt;
            &lt;Status&gt;C&lt;/Status&gt;
          &lt;/NameAddressPhone&gt;
          &lt;VerifiedElementSummary&gt;
            &lt;DOB&gt;XXXXXXXX&lt;/DOB&gt;
            &lt;DOBMatchLevel&gt;8&lt;/DOBMatchLevel&gt;
          &lt;/VerifiedElementSummary&gt;
          &lt;ValidElementSummary&gt;
            &lt;SSNValid&gt;0&lt;/SSNValid&gt;
            &lt;SSNDeceased&gt;0&lt;/SSNDeceased&gt;
            &lt;PassportValid&gt;0&lt;/PassportValid&gt;
            &lt;AddressPOBox&gt;0&lt;/AddressPOBox&gt;
            &lt;AddressCMRA&gt;1&lt;/AddressCMRA&gt;
            &lt;SSNFoundForLexID&gt;0&lt;/SSNFoundForLexID&gt;
          &lt;/ValidElementSummary&gt;
          &lt;NameAddressSSNSummary&gt;2&lt;/NameAddressSSNSummary&gt;
          &lt;ComprehensiveVerification&gt;
            &lt;ComprehensiveVerificationIndex&gt;50&lt;/ComprehensiveVerificationIndex&gt;
            &lt;RiskIndicators&gt;
              &lt;RiskIndicator&gt;
                &lt;RiskCode&gt;A&lt;/RiskCode&gt;
                &lt;Description&gt;Null&lt;/Description&gt;
                &lt;Sequence&gt;1&lt;/Sequence&gt;
              &lt;/RiskIndicator&gt;
              &lt;RiskIndicator&gt;
                &lt;RiskCode&gt;MS&lt;/RiskCode&gt;
                &lt;Description&gt;XXXXXX&lt;/Description&gt;
                &lt;Sequence&gt;2&lt;/Sequence&gt;
              &lt;/RiskIndicator&gt;
              &lt;RiskIndicator&gt;
                &lt;RiskCode&gt;25&lt;/RiskCode&gt;
                &lt;Description&gt;XXXXX&lt;/Description&gt;
                &lt;Sequence&gt;3&lt;/Sequence&gt;
              &lt;/RiskIndicator&gt;
              &lt;RiskIndicator&gt;
                &lt;RiskCode&gt;74&lt;/RiskCode&gt;
                &lt;Description&gt;The input phone number is associated with a different name and address&lt;/Description&gt;
                &lt;Sequence&gt;4&lt;/Sequence&gt;
              &lt;/RiskIndicator&gt;
              &lt;RiskIndicator&gt;
                &lt;RiskCode&gt;52&lt;/RiskCode&gt;
                &lt;Description&gt;The input first name is not associated with input SSN&lt;/Description&gt;
                &lt;Sequence&gt;5&lt;/Sequence&gt;
              &lt;/RiskIndicator&gt;
            &lt;/RiskIndicators&gt;
          &lt;/ComprehensiveVerification&gt;
          &lt;CustomComprehensiveVerification&gt;
            &lt;ComprehensiveVerificationIndex&gt;0&lt;/ComprehensiveVerificationIndex&gt;
          &lt;/CustomComprehensiveVerification&gt;
          &lt;InstantIDVersion&gt;1&lt;/InstantIDVersion&gt;
        &lt;/Result&gt;
      &lt;/response&gt;
    &lt;/FlexIDResponseEx&gt;
  &lt;/Parent&gt;
  </code></pre>
  
  <p>Here is my python script I am trying to write</p>
  
  <pre><code>import os
  from xml.dom.minidom import parse
  
  fileList = []
  p = os.popen('ls *JJ*',"r")
  
  while 1:
      line = p.readline()
      if not line: break
      fileList.append(line)
  
  j = len(fileList)+1
  
  
  for i in range(1, j):
      lnFile = open(fileList[i], "rb")
      tree = parse(lnFile)
      first = tree.find('First')
      first.text = 'YYYY'
      Last = tree.find('Last')
      Last.text = 'ZZZZ'
      tree.write(fileList[i])
      lnFile.close()
  </code></pre>
  
  <p>Here is the stack Trace</p>
  
  <pre><code>/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/parser/parse.py
  Traceback (most recent call last):
    File "/Users/parser/pare.py", line 17, in &lt;module&gt;
      tree = parse(lnFile)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xml/dom/minidom.py", line 1958, in parse
      return expatbuilder.parse(file)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xml/dom/expatbuilder.py", line 913, in parse
      result = builder.parseFile(file)
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xml/dom/expatbuilder.py", line 211, in parseFile
      parser.Parse("", True)
  xml.parsers.expat.ExpatError: no element found: line 1, column 0
  
  Process finished with exit code 1
  </code></pre>
  
  <p>P.S I am using PyCharm CE</p>