Parse string to dom and dom to string

less than 1 minute read

Parse string to dom and dom to string thumb image

Converting Text to DOM and the other way round is an important part of modern Web-Javascript-Development. It’s even more important in the context of widget development for different platforms, which often just provide a key/value store for storing data persistently. That’s where DOMParserand XMLSerializer come to your rescue:

var xmlstring = 'Blink';

var dom = (new DOMParser()).parseFromString(xmlstring, "text/xml");

var stringAgain = (new XMLSerializer()).serializeToString(dom);


Leave a comment — Edit this page on github and issue a PR for your comment please. HowTo?