Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var res = []
function parse(node) {
var i, a, name = node.tagName.toLowerCase()
res.push({type: 'o', name: name})
for (i = 0; i < node.attributes.length; ++i) {
a = node.attributes[i]
res.push({type: 'a', name:, value: a.value})
for (i = 0; i < node.childNodes.length; ++i) {
a = node.childNodes[i]
if (a.nodeType === Node.ELEMENT_NODE)
else if (a.nodeType === Node.TEXT_NODE)
res.push({type: 't', text: a.textContent})
res.push({type: 'c', name: name})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.