// make the extracted tag valid if needed by appending a "/>" to close the tag
if (!validXmlTag) {
var validTag = linkTag.substring(0, linkTag.length - 1) + "/>";
}
parser = new DOMParser();
var xmlDocString = '<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n ' + validTag + '\n</doc>\n';
//this.debug(xmlDocString);
var doc = parser.parseFromString(xmlDocString, "text/xml");