This is how I can parse a well-formed XML document in Java:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
// text contains the XML content
Document doc = builder.parse(new InputSource(new StringReader(text)));
An example for text is this:
<a>
<b/>
</a>
How can I parse a DocumentFragment? For example, this:
<a>
<b/>
</a>
<a>
<b/>
</a>
NOTE: I want to use org.w3c.dom
and no other libraries/technologies, if possible.