title: Is it possible to create a .NET Datatable in VBScript?
body: <p>I have a rest API returning a Datatable, this includes the schema information with it. Here is an example:</p>
  
  <pre><code>&lt;DataSet&gt;
    &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="qryVentListMapping"&gt;
      &lt;xs:element name="qryVentListMapping" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
            &lt;xs:element name="qryVentListMapping" msdata:CaseSensitive="False" msdata:Locale="en-US"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:element name="VentMapId" type="xs:int" minOccurs="0" /&gt;
                  &lt;xs:element name="VentID" type="xs:string" minOccurs="0" /&gt;
                  &lt;xs:element name="PatientID" type="xs:int" minOccurs="0" /&gt;
                  &lt;xs:element name="RoomID" type="xs:string" minOccurs="0" /&gt;
                  &lt;xs:element name="Unit" type="xs:int" minOccurs="0" /&gt;
                  &lt;xs:element name="DeviceCategory" type="xs:string" minOccurs="0" /&gt;
                  &lt;xs:element name="VentType" type="xs:string" minOccurs="0" /&gt;
                  &lt;xs:element name="VentModel" type="xs:string" minOccurs="0" /&gt;
                  &lt;xs:element name="IsActive" type="xs:boolean" minOccurs="0" /&gt;
                  &lt;xs:element name="RoomSeq" type="xs:int" minOccurs="0" /&gt;
                  &lt;xs:element name="DispOrder" type="xs:double" minOccurs="0" /&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
          &lt;/xs:choice&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:schema&gt;
    &lt;diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
      &lt;qryVentListMapping&gt;
        &lt;qryVentListMapping diffgr:id="qryVentListMapping1" msdata:rowOrder="0" diffgr:hasChanges="inserted"&gt;
          &lt;VentMapId /&gt;
          &lt;VentID /&gt;
          &lt;PatientID /&gt;
          &lt;RoomID /&gt;
          &lt;Unit&gt;1&lt;/Unit&gt;
          &lt;DeviceCategory /&gt;
          &lt;VentType /&gt;
          &lt;VentModel /&gt;
          &lt;IsActive&gt;true&lt;/IsActive&gt;
          &lt;RoomSeq /&gt;
          &lt;DispOrder /&gt;
        &lt;/qryVentListMapping&gt;
      &lt;/qryVentListMapping&gt;
    &lt;/diffgr:diffgram&gt;
  &lt;/DataSet&gt;
  </code></pre>
  
  <p>Now I have tried this:</p>
  
  <pre><code>Set dt = CreateObject("System.Data.DataTable")
   dt.ReadXml(objHttp.ResponseText)
  </code></pre>
  
  <p>But it give me this error:     </p>
  
  <blockquote>
    <p>ActiveX component can't create object - Microsoft VBScript runtime
    error      </p>
  </blockquote>
  
  <p>Is there any easy way to deserialize this into something usable in an object without having to load it into a XML document and parse through it (witch i do have working)? The XML returned is sometimes thousands of lines and the function that this is in is called every couple seconds. This is causing high CPU load. I need a more elegant way of dealing with the massive amount of data.</p>
  
  <p>EDIT: Here is the working function I am using now. I am loading everything into a Recordset and using as a replacement of the table. </p>
  
  <pre><code>Function GetRecordSet(PARAMS, Qry)
  
      Dim objXML, rs, child, node, qryNode
      Dim URL
      URL = APPLICATION("UIDS_URL") &amp; PARAMS
      Set objXML = Server.CreateObject("Microsoft.XMLDOM")
      objXML.setProperty "ServerHTTPRequest", True
      objXML.async =  False
      objXML.Load URL
      Err.number = objXML.parseError.errorCode 
      objXML.setProperty "SelectionLanguage", "XPath"
  
      dim objNodeList : Set objNodeList = objXML.selectNodes( "//"&amp;Qry ) 
  
      Set rs = CreateObject("ADODB.Recordset")
      rs.CursorType = 1 ' adOpenKeyset
          rs.LockType = 4 ' adLockBatchOptimistic
          rs.CursorLocation = 2 'adUseClient
  
      If 0 &lt;&gt; objNodeList.length Then 
  
  
          set qryNode = objNodeList(0)
  
          Set node = objXML.selectSingleNode("//"&amp;Qry)
          For Each child in node.ChildNodes            
              rs.Fields.Append child.NodeName, 8, 10, 4             
          Next   
  
          rs.open   
  
          For Each node in objNodeList
              rs.AddNew          
              For Each child in node.ChildNodes            
                  rs.Fields(child.NodeName).Value = child.Text  
  
              Next
              rs.Update   
          Next  
          Set rs.ActiveConnection = Nothing
          rs.MoveFirst    
  
      end if        
  
     Set GetRecordSet = rs   
  
  End Function
  </code></pre>
  
  <p>Example usage of the function:</p>
  
  <pre><code>Set rs = GetRecordSet ("CQryVentDataDetail?VentId="&amp;VentId&amp;"&amp;InputValue="&amp;InputValue, "qryVentDataDetail")
  </code></pre>