Skip to content

Instantly share code, notes, and snippets.

@DylanCh
Last active July 20, 2019 05:00
Show Gist options
  • Save DylanCh/63fe5e95bbc8756074a69f9544450861 to your computer and use it in GitHub Desktop.
Save DylanCh/63fe5e95bbc8756074a69f9544450861 to your computer and use it in GitHub Desktop.
fetch('https://json.org/example.html')
.then( x => x.text())
.then(function(html){
var parser = new DOMParser();
var doc = parser.parseFromString(html, "text/html");
var pre = doc.querySelector('pre');
var obj = JSON.parse(pre.innerHTML);
console.log(obj.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso[0])
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment