/    Sign up×
Community /Pin to ProfileBookmark

This is my first post in this forum, so Hi all!

Does anyone has experience with manipulating DOM XML with Javascript?

I would like to serialize a HTML node to a XML string using Javascript.

In Firefox browsers it’s pretty easy. You just use the built-in XMLSerializer class:

var myNode = document.getElementById(‘properties’);
var xmlString = new XMLSerializer().serializeToString( myNode );

But what about the others browsers? I searched a lot and couldn’t find any information, even for Internet Explorer. I seems the other browsers lack a function like that one.

Does anyone has any experience with this ? Please help !

Thank you
Michael Scofield

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 11.2008 — Could be:
<i>
</i>function getXMLNodeSerialisation(xmlNode) {
var text = false;
try {
// Gecko-based browsers, Safari, Opera.
var serializer = new XMLSerializer();
text = serializer.serializeToString(xmlNode);
}
catch (e) {
try {
// Internet Explorer.
text = xmlNode.xml;
}
catch (e) {}
}
return text;
}
Copy linkTweet thisAlerts:
@rnd_meJul 11.2008 — in IE, element.outerHTML should always be well-formed xml.
×

Success!

Help @Michael_Scofiel2 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 5.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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