}
private void parse(Document doc) {
E bodyElement = Blips.getBody(doc);
if (bodyElement != null) {
N child = doc.getFirstChild(bodyElement);
while (child != null) {
T asText = doc.asText(child);
int xmlPos = doc.getLocation(child);
if (asText != null) {
bits.add(new Bit(doc.getData(asText), xmlPos));
} else {
E xmlElement = doc.asElement(child);
if (xmlElement != null) {
Element element = ElementSerializer.xmlToApiElement(doc, xmlElement, wavelet);
// element can be null, but we still want to note that there
// was something unknown.
N next = doc.getNextSibling(child);
int xmlSize;
if (next != null) {
xmlSize = doc.getLocation(next) - xmlPos;
} else {
// At the end of the document. XmlSize is the rest.