title: Ignoring "Content is not allowed in trailing section" SAXException
body: <p>I'm using Java's <code>DocumentBuilder.parse(InputStream)</code> to parse an XML document.  Occasionally, I get malformed XML documents in that there is extra junk after the final <code>&gt;</code> that causes a <code>SAXException: Content is not allowed in trailing section</code>.  (In the cases I've seen, the junk is simply one or more null bytes.)</p>
  
  <p>I don't care what's after the final <code>&gt;</code>.  Is there an easy way to parse an entire XML document in Java and have it ignore any trailing junk?</p>
  
  <p>Note that by "ignore" I don't simply mean to catch and ignore the exception: I mean to ignore the trailing junk, throw no exception, and to return the <code>Document</code> object since the XML up to an including the final <code>&gt;</code> is valid.</p>