C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » XML »

Read an XML File using VB.Net


Posted Date: 04 Jul 2009    Resource Type: Code Snippets    Category: XML
Author: R.VijayaragavanMember Level: Gold    
Rating: 1 out of 5Points: 4



Abstract:


This code shows how to read an XML File in VB.net.

Code:




Imports System.IO
Imports System.Xml

Public Class ReadXMLFile

Shared Sub Main()

Dim document As XmlDocument = New XmlDocument()
document.Load("ReadingXML.xml")

' create XmlNodeReader for document
Dim reader As XmlNodeReader = New XmlNodeReader(document)

' display each node's content
While reader.Read

Select Case reader.NodeType

' if Element, display its name
Case XmlNodeType.Element

' increase tab depth
Console.WriteLine("<" & reader.Name & ">" )

' if empty element, decrease depth
If reader.IsEmptyElement Then
Console.WriteLine("Element is Empty")
End If

Case XmlNodeType.Comment ' if Comment, display it
Console.WriteLine("" )

Case XmlNodeType.Text ' if Text, display it
Console.WriteLine(reader.Value )

' if XML declaration, display it
Case XmlNodeType.XmlDeclaration
Console.WriteLine(" reader.Value & "?>" )

' if EndElement, display it and decrement depth
Case XmlNodeType.EndElement
Console.WriteLine("" )
End Select
End While
End Sub ' Main
End Class



Responses

Author: Miss Meetu Choudhary    04 Jul 2009Member Level: Diamond   Points : 1
Please Format your resource properly.

++
Thanks and Regards
Meetu Choudhary
Site Coordinator.



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
XML  .  Read an XML File using VB.Net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Transforming XML with XSLT on the Server
Previous Resource: Beautify your XML
Return to Discussion Resource Index
Post New Resource
Category: XML


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use