Is there a way to JSON.stringify an HTML dom object? [JavaScript]
问题 I am trying to load in a external html file and stringify the contents within the body but can't seem to do so without it producing undesired results. Is there even a way to do this? var xhr = new XMLHttpRequest(); function loadFile(){ xhr.open("GET", 'index.html'); xhr.responseType = "document"; xhr.send(); } xhr.onload = function(data) { myData = data; myString = JSON.stringify(myData.srcElement.responseXML.body.children); console.log(myString) //logs: {"0":{},"length":1} } loadFile(); But