title: How to obtain an ADORecordset from XML in VB6?
body: <p>I have a requirement that my program should navigate between XML data source and SQL server. I have to read records from the XML file and have to return <code>ADORecordset</code>.</p>
  
  <p>Here is the rough piece of code (<code>Form1</code>):</p>
  
  <pre class="lang-vb prettyprint-override"><code>if (optionDB) then
    GetDBRecords 'this function should return recordset
  else 
    GetXMLRecords ' this function should return Recordset
  end if
  
  Module1: ' this module contains code related to DB
  
  Module2: ' This module should contain code related to XML
  
  Public Function getXmlRecords() As ADODB.Recordset
      Dim oXMLDom As New DOMDocument
      Dim Recordset As New ADODB.Recordset
  
      If oXMLDom.Load(App.Path + "\data.xml") = False Then
          MsgBox "Failed to load xml data from file."
      End If
      Set Recordset = RecordsetFromXMLDocument(oXMLDom)
  End Function
  
  Public Function RecordsetFromXMLDocument(XMLDOMDocument As DOMDocument) As Recordset
      Dim oRecordset As ADODB.Recordset
  
      Set oRecordset = New ADODB.Recordset
      oRecordset.Open XMLDOMDocument ' pass the DOM Document instance as the Source argument
      Set RecordsetFromXMLDocument = oRecordset  ' return the recordset
      Set oRecordset = Nothing
  End Function
  </code></pre>
  
  <p>It is throwing me this error:</p>
  
  <blockquote>
    <p>Recordset cannot be created.Source XML is incomplete or invalid.</p>
  </blockquote>
  
  <p>What should i add to the XML document? I am new to these concepts.</p>