Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 25th, 2004, 11:03 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.NET: Get the Attribute and Text out from Xml

Say I have this Xml taken as an 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> 
            <Register> 
               <Time hour="23" min=40"> 
               <Date>22/10/78</Date> 
            </Register> 
 </Connection> 
 <Connection> 
        <UserID>sa</UserID> 
        <DataSource>Server</DataSource> 
        <InitialCatalog>Database</InitialCatalog> 
            <Register> 
               <Time hour="23" min=40"> 
               <Date>22/10/78</Date> 
            </Register> 
 </Connection> 
</Settings>
Right now, there is one more Childnodes and Subchild in the Register and Time tag...

How to create a loop to get the "23" or "40" plus the DataSource out from the Xml tag using the above ChildNodes method....

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

Any suggestion or link will be appreciated...

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net, adding XML data to an existing XML file saikoboarder XML 11 April 17th, 2008 04:19 PM
How to Edit Attribute Value in XML by ASP.Net sibajibasak XML 1 January 20th, 2005 02:07 AM
ASP.Net/VB.Net Text Editor joevnvdvc Classic ASP Basics 0 July 29th, 2003 03:56 PM
Text Editing/Modification in VB.Net/ASP.Net joevnvdvc VS.NET 2002/2003 0 July 29th, 2003 12:56 PM
XML to XML through an XSLT (VB.NET) dimondwoof XSLT 1 June 25th, 2003 12:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.