title: Fatal Error :1:1: Content is not allowed in prolog. org.xml.sax.SAXParseException
body: <p>I am trying to read an XML file in Java and then compare it against its XML Schema but I can't get past this error :</p>
  
  <blockquote>
    <p>[Fatal Error] :1:1: Content is not allowed in prolog.
        org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.</p>
  </blockquote>
  
  <p>This is the start of the file reading</p>
  
  <pre><code>try {
          DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();          
          Document doc = dBuilder.parse(new InputSource(new StringReader("myfile.xml"))); // ERROR OCCURS HERE
  </code></pre>
  
  <p>I scanned my XML through HEX Editors but I did not find any weird characters inside, so I dont know where the problem is</p>
  
  <p><strong>myfile.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  
  &lt;Schedule xmlns ="schedule"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="schedule.xsd"&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;Artificial Intelligence&lt;/Title&gt;
          &lt;Lecture Classroom="BA"&gt;
              &lt;Day&gt;Wednesday&lt;/Day&gt;
              &lt;Time&gt;09-11&lt;/Time&gt;
          &lt;/Lecture&gt;
          &lt;Professor&gt;Hatzilygeroudis&lt;/Professor&gt;
      &lt;/Lesson&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;Constraint Satisfaction Problems&lt;/Title&gt;
          &lt;Lecture Classroom="B3"&gt;
              &lt;Day&gt;Monday&lt;/Day&gt;
              &lt;Time&gt;19-21&lt;/Time&gt;
          &lt;/Lecture&gt;
      &lt;/Lesson&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;Knowledge Representation in Web&lt;/Title&gt;
          &lt;Lecture Classroom="P200"&gt;
              &lt;Day&gt;Friday&lt;/Day&gt;
              &lt;Time&gt;15-17&lt;/Time&gt;
          &lt;/Lecture&gt;
          &lt;Professor&gt;Hatzilygeroudis&lt;/Professor&gt;
      &lt;/Lesson&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;Artificial Intelligence&lt;/Title&gt;
          &lt;Lecture&gt;
              &lt;Day&gt;Monday&lt;/Day&gt;
              &lt;Time&gt;19-21&lt;/Time&gt;
          &lt;/Lecture&gt;
      &lt;/Lesson&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;AI Programming&lt;/Title&gt;
          &lt;Lecture Classroom="B3"&gt;
              &lt;Day&gt;Monday&lt;/Day&gt;
              &lt;Time&gt;11-13&lt;/Time&gt;
          &lt;/Lecture&gt;
      &lt;/Lesson&gt;
      &lt;Lesson&gt;
          &lt;Title&gt;Introduction to Procedural Programming&lt;/Title&gt;
          &lt;Lecture Classroom="P200"&gt;
              &lt;Day&gt;Wednesday&lt;/Day&gt;
              &lt;Time&gt;15-17&lt;/Time&gt;
          &lt;/Lecture&gt;
          &lt;Professor&gt;Papadopoulos&lt;/Professor&gt;
      &lt;/Lesson&gt;
  &lt;/Schedule&gt;
  </code></pre>