Parsing Locally Registered SQL Server names XML file using Vb .Net
<p>I need to retrieve names of the locally registered MS SQL Servers that get stored in a XML file. This is usually located at "C:\Users\XYZ\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\RegSrvr.xml" </p>

<p>Once retrieved, I need to populate these in a combobox. I am using below code. But could not figure out which tag to use from this xml for the "m_xmld.SelectNodes" code. Any advise is appreciated. </p>

<pre><code> If System.IO.File.Exists(RegSrvrFile) Then
                Dim m_xmld As XmlDocument
                Dim m_nodelist As XmlNodeList
                Dim m_node As XmlNode
                'Create the XML Document
                m_xmld = New XmlDocument()
                'Load the Xml file
                m_xmld.Load(RegSrvrFile)
                'Get the list of name nodes 
                m_nodelist = m_xmld.SelectNodes("/model/instances/document/data/RegisteredServers")
            End If
        End If
</code></pre>

<p>Sample XML is attached. </p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;model xmlns="http://schemas.serviceml.org/smlif/2007/02"&gt;
  &lt;identity&gt;
    &lt;name&gt;urn:uuid:96fe1236-abf6-4a57-b54d-e9baab394fd1&lt;/name&gt;
    &lt;baseURI&gt;http://documentcollection/&lt;/baseURI&gt;
  &lt;/identity&gt;
  &lt;xs:bufferSchema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;definitions xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08"&gt;
      &lt;document&gt;
        &lt;docinfo&gt;
          &lt;aliases&gt;
            &lt;alias&gt;/system/schema/RegisteredServers&lt;/alias&gt;
          &lt;/aliases&gt;
          &lt;sfc:version DomainVersion="1" /&gt;
        &lt;/docinfo&gt;
        &lt;data&gt;
          &lt;xs:schema targetNamespace="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt;
            &lt;xs:element name="RegisteredServersStore"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:any namespace="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" processContents="skip" minOccurs="0" maxOccurs="unbounded" /&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="ServerGroup"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:any namespace="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" processContents="skip" minOccurs="0" maxOccurs="unbounded" /&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name="RegisteredServer"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:any namespace="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" processContents="skip" minOccurs="0" maxOccurs="unbounded" /&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;RegisteredServers:bufferData xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08"&gt;
              &lt;instances xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08"&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:RegisteredServersStore xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:ServerGroups&gt;
                        &lt;sfc:Collection&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/AnalysisServicesServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/CentralManagementServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/DatabaseEngineServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/IntegrationServicesServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/ReportingServicesServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/SqlServerCompactEditionServerGroup&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                        &lt;/sfc:Collection&gt;
                      &lt;/RegisteredServers:ServerGroups&gt;
                    &lt;/RegisteredServers:RegisteredServersStore&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/AnalysisServicesServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;AnalysisServicesServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;AnalysisServices&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/CentralManagementServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;CentralManagementServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;DatabaseEngine&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/DatabaseEngineServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:RegisteredServers&gt;
                        &lt;sfc:Collection&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/DatabaseEngineServerGroup/RegisteredServer/MYSQLSERVER\DBInstance&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                        &lt;/sfc:Collection&gt;
                      &lt;/RegisteredServers:RegisteredServers&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;DatabaseEngineServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;DatabaseEngine&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/DatabaseEngineServerGroup/RegisteredServer/MYSQLSERVER\DBInstance&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:RegisteredServer xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/DatabaseEngineServerGroup&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;MYSQLSERVER\DBInstance&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerName type="string"&gt;MYSQLSERVER\DBInstance&lt;/RegisteredServers:ServerName&gt;
                      &lt;RegisteredServers:UseCustomConnectionColor type="boolean"&gt;false&lt;/RegisteredServers:UseCustomConnectionColor&gt;
                      &lt;RegisteredServers:CustomConnectionColorArgb type="int"&gt;0&lt;/RegisteredServers:CustomConnectionColorArgb&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;DatabaseEngine&lt;/RegisteredServers:ServerType&gt;
                      &lt;RegisteredServers:ConnectionStringWithEncryptedPassword type="string"&gt;data source=MYSQLSERVER\DBInstance;integrated security=True;pooling=False;multipleactiveresultsets=False&lt;/RegisteredServers:ConnectionStringWithEncryptedPassword&gt;
                      &lt;RegisteredServers:CredentialPersistenceType type="CredentialPersistenceType"&gt;PersistLoginName&lt;/RegisteredServers:CredentialPersistenceType&gt;
                    &lt;/RegisteredServers:RegisteredServer&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/IntegrationServicesServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:RegisteredServers&gt;
                        &lt;sfc:Collection&gt;
                          &lt;sfc:Reference sml:ref="true"&gt;
                            &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/IntegrationServicesServerGroup/RegisteredServer/MYSQLSERVER&lt;/sml:Uri&gt;
                          &lt;/sfc:Reference&gt;
                        &lt;/sfc:Collection&gt;
                      &lt;/RegisteredServers:RegisteredServers&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;IntegrationServicesServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;IntegrationServices&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/IntegrationServicesServerGroup/RegisteredServer/MYSQLSERVER&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:RegisteredServer xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore/ServerGroup/IntegrationServicesServerGroup&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;MYSQLSERVER&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerName type="string"&gt;MYSQLSERVER&lt;/RegisteredServers:ServerName&gt;
                      &lt;RegisteredServers:UseCustomConnectionColor type="boolean"&gt;false&lt;/RegisteredServers:UseCustomConnectionColor&gt;
                      &lt;RegisteredServers:CustomConnectionColorArgb type="int"&gt;0&lt;/RegisteredServers:CustomConnectionColorArgb&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;IntegrationServices&lt;/RegisteredServers:ServerType&gt;
                      &lt;RegisteredServers:ConnectionStringWithEncryptedPassword type="string"&gt;server=MYSQLSERVER&lt;/RegisteredServers:ConnectionStringWithEncryptedPassword&gt;
                      &lt;RegisteredServers:CredentialPersistenceType type="CredentialPersistenceType"&gt;PersistLoginName&lt;/RegisteredServers:CredentialPersistenceType&gt;
                    &lt;/RegisteredServers:RegisteredServer&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/ReportingServicesServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;ReportingServicesServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;ReportingServices&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
                &lt;document&gt;
                  &lt;docinfo&gt;
                    &lt;aliases&gt;
                      &lt;alias&gt;/RegisteredServersStore/ServerGroup/SqlServerCompactEditionServerGroup&lt;/alias&gt;
                    &lt;/aliases&gt;
                    &lt;sfc:version DomainVersion="1" /&gt;
                  &lt;/docinfo&gt;
                  &lt;data&gt;
                    &lt;RegisteredServers:ServerGroup xmlns:RegisteredServers="http://schemas.microsoft.com/sqlserver/RegisteredServers/2007/08" xmlns:sfc="http://schemas.microsoft.com/sqlserver/sfc/serialization/2007/08" xmlns:sml="http://schemas.serviceml.org/sml/2007/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
                      &lt;RegisteredServers:Parent&gt;
                        &lt;sfc:Reference sml:ref="true"&gt;
                          &lt;sml:Uri&gt;/RegisteredServersStore&lt;/sml:Uri&gt;
                        &lt;/sfc:Reference&gt;
                      &lt;/RegisteredServers:Parent&gt;
                      &lt;RegisteredServers:Name type="string"&gt;SqlServerCompactEditionServerGroup&lt;/RegisteredServers:Name&gt;
                      &lt;RegisteredServers:ServerType type="ServerType"&gt;SqlServerCompactEdition&lt;/RegisteredServers:ServerType&gt;
                    &lt;/RegisteredServers:ServerGroup&gt;
                  &lt;/data&gt;
                &lt;/document&gt;
              &lt;/instances&gt;
            &lt;/RegisteredServers:bufferData&gt;
          &lt;/xs:schema&gt;
        &lt;/data&gt;
      &lt;/document&gt;
    &lt;/definitions&gt;
  &lt;/xs:bufferSchema&gt;
&lt;/model&gt;
</code></pre>