Best way to parse HTML in Javascript

Do the following steps:

  1. Create a new documentFragment
  2. Put your HTML string in it
  3. Use selectors to get what you want

Why do all the parsing work – which won’t work anyways, since HTML is not parsable via RegExp – when you have the best HTML parser available? (the Browser)

Leave a Comment