Results 1 to 6 of 6

Thread: VB.NET: Getting Attributes and Text out from Xml 2....[Resolved]

Threaded View

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Thumbs up VB.NET: Getting Attributes and Text out from Xml 2....[Resolved]

    Say I have this Xml taken from one of the threads as example:
    Code:
    <Settings>
      <Connection>
             <UserID>sa</UserID>
             <DataSource>Server</DataSource>
             <InitialCatalog>Database</InitialCatalog>
      </Connection>
    </Settings>
    To get the Xml text is:
    Code:
      Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
        
        m_xmld = New XmlDocument()
    
        m_xmld.Load("Settings.xml")
    
        m_nodelist = m_xmld.SelectNodes("/Settings/Connection")
        
        For Each m_node In m_nodelist
           Dim UserID = m_node.ChildNodes.Item(0).InnerText
           Dim DataSource = m_node.ChildNodes.Item(1).InnerText
           Dim InitialCatalog = m_node.ChildNodes.Item(2).InnerText
        Next
    How about if i add in one time tag...
    Code:
    <Settings>
      <Connection>
             <UserID>sa</UserID>
             <DataSource>Server</DataSource>
             <InitialCatalog>Database</InitialCatalog>
             <Time hour="23" min="40">
      </Connection>
      <Connection>
             <UserID>sa</UserID>
             <DataSource>Server</DataSource>
             <InitialCatalog>Database</InitialCatalog>
             <Time hour="23" min="40">
      </Connection>
    </Settings>
    How do i use the above node.ChildNodes method to get the "23" or "40" out from the Xml tag....

    I need to loop through all the nodes...and I am using XmlDocument...

    Any suggestion or link will be appreciated...

    Thanks
    Last edited by toytoy; Dec 3rd, 2004 at 07:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width