Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 25th, 2004, 11:03 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:05 AM.


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