JSFiddle - React, Tailwind, and code Playground
HTML
<input id="test:1" value=test1 />
JavaScript
var str = "<?xml version='1.0' encoding='utf-8'?><xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:output method='text' encoding='utf-8' /><xsl:variable name='title'>aaa</xsl:variable><xsl:variable name='col1'>CSV00001</xsl:variable><xsl_variable name='test'>test</xsl_variable></xsl:stylesheet>";
function StringtoXML(text){
if (window.ActiveXObject){
var doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(text);
} else {
var parser=new DOMParser();
var doc=parser.parseFromString(text,'text/xml');
}
return doc;
}
var csvXsl = StringtoXML(str);
alert("input tag works -- " + $("#test\\:1").val());
alert("this works, too -- " + $(csvXsl).find("xsl_variable")[0]);
alert("But when I try to escape the colon to access the xsl:variable tag, it comes up as undefined...");
var nodes = $(csvXsl).find("xsl\\:variable")[0];
alert(nodes);