title: Why is DocumentBuilder.parse() not working
body: <p>I have read several posts about how to use the <code>DocumentBuilder.parse()</code> function for getting a document object. </p>
  
  <pre><code>Document document = builder.parse(new InputSource(new StringReader(xml)));
  </code></pre>
  
  <p>was returning <code>[#document: null]</code> which as I found does not necessarily mean it is empty. However, after inspecting it more, I have found that it is in fact empty.</p>
  
  <p>I am building the String xml and have used an xml validator, (and pasted into eclipse and <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>f</kbd> to format it. This is usually my first try to see if something is well formed) to show it is valid xml. I decided to break out each part of the <code>parse()</code> parameters so I could step through and watch to make sure they were working correctly.</p>
  
  <p>My code is:</p>
  
  <pre><code>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  DocumentBuilder builder;        
  try {
      builder = factory.newDocumentBuilder();
      StringReader sr = new StringReader(xml);
      InputSource is = new InputSource(sr);
      Document document = builder.parse(is);          
  
      return document;
  } catch(Exception e){
      e.printStackTrace();
  }
  </code></pre>
  
  <p>sr and is appear to work correctly until I execute the builder.parse(is) line. As soon as this executes, the sr.str value becomes null and same with is.characterInputStream.str. This seems odd to me, is this expected? This has been driving me crazy, any input would be great!</p>
  
  <p>edit- my xml string is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;rss version="2.0"&gt;
      &lt;channel&gt;
          &lt;title&gt;Feed Title&lt;/title&gt;
          &lt;link&gt;Feed Link&lt;/link&gt;
          &lt;description&gt;Feed Description&lt;/description&gt;
          &lt;item&gt;
              &lt;title&gt;Item Title&lt;/title&gt;
              &lt;link&gt;Item Link&lt;/link&gt;
              &lt;description&gt;Item Description&lt;/description&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;title&gt;Another Item&lt;/title&gt;
              &lt;link&gt;Another Link&lt;/link&gt;
              &lt;description&gt;Another Description&lt;/description&gt;
          &lt;/item&gt;
      &lt;/channel&gt;
  &lt;/rss&gt;
  </code></pre>