* @param selectionListener
* @return new document
*/
public D parseIntoDocument(
String xmlString, SelectionParsingListener<N> selectionListener) {
SafeXmlPullParser parser;
try {
parser = XmlParserFactory.buffered(xmlString);
} catch (XmlParseException e) {
throw new RuntimeException("Cannot parse xml: " + xmlString, e);
}
while (parser.getCurrentType() != ItemType.START_ELEMENT) {
parser.next();
}
D doc = factory.create(parser.getTagName(), CollectionUtils.newJavaMap(parser.getAttributes()));
parseChildren(parser, selectionListener, doc, doc.getDocumentElement());
return doc;
}