title: How do I store xml as a string variable in javascript?
body: <p>I trying to store a piece of xml into a string variable in javascript and in IE8 it keeps throwing an error.  FireFox doesn't show the error but of course in IE8 it does.  Swictching browsers isn't an option so I have to try to solve this one.  </p>
  
  <p>The purpose of the function is to check if the items of a list exist in an xml object or not.  So if there is a better way to do that check I am open to that as well. The system we pull from has a function to convert the xml to a string.  At the bottom is an output of what that retrieves. Here is the function. </p>
  
  <pre><code>function commodityExists(newCommodityCode){
          var comExists = new Boolean(0);
          newCommodityCode =  "&gt;" + newCommodityCode + "&lt;"
          var strXML = 'tw.local.aribaHeader.commodities.toXMLString()';  //ERROR HERE
          strXML = strXML.toString();
          if(strXML.indexOf(newCommodityCode,0)&gt;0){            
              comExists=true;            
          }
          return comExists;
      };  
  </code></pre>
  
  <p>Here is the output from strXML.toString();  but as you can see it is essentially xml.</p>
  
  <pre><code>        var strXML = ‘&lt;variable type="NameValuePair[]"&gt;
                        &lt;item type="NameValuePair"&gt;
                        &lt;name type="String"&gt;&lt;![CDATA[No Data Found]]&gt;&lt;/name&gt;
                        &lt;value type="String"&gt;&lt;![CDATA[95990070]]&gt;&lt;/value&gt;
                        &lt;/item&gt;
                        &lt;/variable&gt;’;
  </code></pre>