diff --git a/src/html2json.js b/src/html2json.js
index 65a3595..01a7c3c 100644
--- a/src/html2json.js
+++ b/src/html2json.js
@@ -113,10 +113,10 @@
text: text,
};
var parent = bufArray[0];
- if (parent.child === undefined) {
+ if (parent && parent.child === undefined) {
parent.child = [];
}
- parent.child.push(node);
+ if(parent)parent.child.push(node);
},
});
return results;