Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 955 Bytes

File metadata and controls

28 lines (21 loc) · 955 Bytes

HTMLParser

Updated version of John Resig's htmlparser.js - read blog post
Which was based on Erik Arvidsson's simplehtmlparser.js

  • toDOM() removed, was not needed
  • this context corrected for WScript
  • throw Error() to work for WScript
  • toXMLString can pass in tag(), attr()
  • makeMap will also make uppercase versions

Usage

var xmlString = HTMLParser.toXMLString(htmlString)

or

var xmlString = HTMLParser.toXMLString(
                  htmlString,
                  function(tag) {
                    return tag.toLowerCase()
                  },
                  function(attr) {
                    attr.escaped = attr.escaped.replace(/&/g, '&')
                    return attr
                  }
                )