title: Why is jquery's parseXML function failing when the XML looks ok?
body: <p>I have a pretty simple bit of javascript that attempt to parse the xml I've extracted from the metadata in a jpeg:              </p>
  
  <pre><code>var xmlDoc;
  try {
      xmlDoc = $.parseXML(xmlString);
  } catch(e) {
      console.log(e);
  }
  </code></pre>
  
  <p>Here is the exception that gets thrown:</p>
  
  <pre><code>Invalid XML: &lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0"&gt;
     &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
        &lt;rdf:Description rdf:about=""
              xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"&gt;
           &lt;photoshop:Instructions&gt;C1DDZVs9Sr+DG5R9eSc%9w&lt;/photoshop:Instructions&gt;
        &lt;/rdf:Description&gt;
        &lt;rdf:Description rdf:about=""
              xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"&gt;
           &lt;aux:SerialNumber&gt;1&lt;/aux:SerialNumber&gt;
           &lt;aux:Lens&gt;AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]&lt;/aux:Lens&gt;
           &lt;aux:LensID&gt;1&lt;/aux:LensID&gt;
           &lt;aux:ImageNumber&gt;6651&lt;/aux:ImageNumber&gt;
           &lt;aux:FlashCompensation&gt;0/1&lt;/aux:FlashCompensation&gt;
        &lt;/rdf:Description&gt;
     &lt;/rdf:RDF&gt;
  &lt;/x:xmpmeta&gt;
  </code></pre>
  
  <p>There doesn't seem to be anything wrong with that XML. In fact, if I cut and paste that xml in directly, no exception is thrown:</p>
  
  <pre><code>var xmlDoc;
  try {
      xmlDoc = $.parseXML('&lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0"&gt;       &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;          &lt;rdf:Description rdf:about=""                xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"&gt;             &lt;photoshop:Instructions&gt;C1DDZVs9Sr+DG5R9eSc%9w&lt;/photoshop:Instructions&gt;          &lt;/rdf:Description&gt;          &lt;rdf:Description rdf:about=""                xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"&gt;             &lt;aux:SerialNumber&gt;1&lt;/aux:SerialNumber&gt;             &lt;aux:Lens&gt;AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]&lt;/aux:Lens&gt;             &lt;aux:LensID&gt;1&lt;/aux:LensID&gt;             &lt;aux:ImageNumber&gt;6651&lt;/aux:ImageNumber&gt;             &lt;aux:FlashCompensation&gt;0/1&lt;/aux:FlashCompensation&gt;          &lt;/rdf:Description&gt;       &lt;/rdf:RDF&gt;    &lt;/x:xmpmeta&gt;' );
  } catch(e) {
      console.log("error parsing xml: " + e);
  }
  </code></pre>
  
  <p>I can only assume that there must be some kind of unprintable special character in there somewhere that is causing the trouble. How can I test that assumption and fix it, or perhaps something else is wrong?</p>