title: Reading XML CDATA section with ]] in it
body: <p>I'm coding a RSS reader in Javascript using <code>XMLHttpRequest</code>.</p>
  
  <p>For some RSS Feeds I had no problems but in some cases the <code>xmlDocument.firstChild</code> attribute was always <code>NULL</code></p>
  
  <p>After trying to see the differences between the XML that worked and the ones that didn't worked I found that the following is the cause of the error.</p>
  
  <pre><code>&lt;item&gt;
      &lt;description&gt;
          &lt;![CDATA[This is a description for a test [...]]]&gt;
      &lt;/description&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>Because that in this description tag I have a closing bracket followed by the closing brackets of the CDATA is causing my error, I've made a code with C# using LINQ for the same XML and everything worked.</p>
  
  <p>The closing bracket that is just before the closing brackets of CDATA is causing this strange behaviour. As a test I've tried to read the same XML using C# and LINQ, everything worked okay. </p>
  
  <p>Then I tried to add a space between the closing brackets, like the following</p>
  
  <p><code>&lt;![CDATA[This is a description for a test [...] ]]&gt;</code></p>
  
  <p>And it worked! </p>
  
  <p>my javascript code</p>
  
  <pre><code>function LoadRSS() {
      http_request.onreadystatechange = function () { showContent(http_request); };
      http_request.open("GET", "./feeds/test.xml", true);
      http_request.send(false);
  }
  
  
  function showContent(http_request) {
      if (http_request.readyState == 4) {
          if (http_request.status == 200) {
              var parser = new DOMParser();
              var xml_doc = parser.parseFromString(http_request.responseText, "text/xml");
              alert(xml_doc.firstChild)
          }
          else {
              xml_doc = null;
          }
      }
  }
  </code></pre>
  
  <p>Does anyone have faced something similar? Now I really don't know how to proceed any comments and suggestions are welcomed.</p>