code: function extractTextContent (node) {
      var buf = []
      var textContent
      
      switch (node.nodeType) {
        case 1: // Element node such as <p> or <div>
        case 11: // A DocumentFragment node ( a minimal document object that has no parent)
          node = node.firstChild
          while (node) {
            // Type 7 = a ProcessingInstruction of an XML document such as <?xml-stylesheet ... ?> declaration
            // Type 8 = a Comment node
            if (node.nodeType !== 7 && node.nodeType !== 8) {
              textContent = extractTextContent(node)
              
              if (textContent.length > 0 && buf.length > 0) {
                var previousTextContent = buf[buf.length - 1]
                
                if (textContent[0] !== ' ' && previousTextContent.length > 0 && previousTextContent[previousTextContent.length - 1] !== ' ') {
                  buf.push(' ')
                }
              }
              
              buf.push(textContent)
            }
            node = node.nextSibling
          }
          return buf.join('')
        default:
          return node.nodeValue
      }
    }
docs: Code modified from getTextContent in xmldom/dom.js - https://github.com/jindw/xmldom Node number documentation from https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType