// Private - use XmlScripts.inc
// Wrapper around MSParser

function parseXmlImplIE(s)
{
   var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   xmlDoc.async = false;
   xmlDoc.loadXML(s);
   return buildChild(xmlDoc.documentElement);
}

function buildChild(child)
{
   if(child.childNodes.length>0 && child.childNodes[0].nodeType==1)
   {
      var c = new XmlElement(child.nodeName);
      var attrs=child.attributes;
      for(var i=0; i<attrs.length; i++)
      	c.attributes[attrs.item(i).name] = attrs.item(i).value;

      var children = child.childNodes;
      for(var i=0; i<children.length; i++)
      {
         c.children[c.children.length] = buildChild(children[i]);
      }
      return c;
   }
   else
   {
      var c = new XmlElement(child.nodeName, (child.childNodes[0]?child.childNodes[0].text:""));
      var attrs=child.attributes;
      for(var i=0; i<attrs.length; i++)
      	c.attributes[attrs.item(i).name] = attrs.item(i).value;
      return c;
   }
}