/    Sign up×
Community /Pin to ProfileBookmark

new html dom document

How do you create a new html dom document? So here’s the situation. I have a string that is returned from an xmlHTTPRequest, and I need to create a document from it, manipulate the dom, and then turn it back into a string.(I know this sounds silly but I have to do this) I can create an xml document using the function below:

function parseXMLTextToDOMDocument(xmlText) {

// uses browser detection
if (browser == ‘ie’) {
var doc = new ActiveXObject(“Microsoft.XMLDOM”);
doc.async=”false”;
var text = xmlText;
doc.loadXML(text);

}

return doc;
}

This will give me an xml document, which means I cannot use things such as doc.documentElement.className;

I need an html document to use className in this way. How do I do this? I thought perhaps I should use something like

doc = new HTMLDocument()
doc.write(string)

Perhaps there is a create html dom document function that I do not know about. Should I use a document fragment? help!!!!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Adan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...