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 » Articles » General »

To read a XML file in vb.net


Posted Date: 21 Aug 2008    Resource Type: Articles    Category: General
Author: D.Jeya kumar(JK)Member Level: Diamond    
Rating: 1 out of 5Points: 7



To read a XML file

Sample XML file

<?xml version="1.0" encoding="utf-8"?>
<ConfigValues>
<add key="test1" value="test" />
<add key="Path" value="C:\" />
<add key="Emptynode" value="" />
</ConfigValues>

To get the node value of test you need to call the function like the below line

To_GetValueOfNode(“test1”)

Public Function To_GetValueOfNode(ByVal StrNodeKeyName As String) As String
Try
Dim strstrNameAttribute As String = ""
Dim strValueArrtibute As String = ""
Dim strusername As String = ""
Dim xtReader As XmlTextReader

xtReader = New XmlTextReader(“Path of the XML file”)

xtReader.WhitespaceHandling = WhitespaceHandling.None
'read the xml declaration and advance to family tag
xtReader.Read()

'Load the Loop
While Not xtReader.EOF
xtReader.Read()
'if not start element exit while loop
If Not xtReader.IsStartElement() Then
Exit While
End If
'Values from Admin option xml
strstrNameAttribute = xtReader.GetAttribute("key")
strValueArrtibute = xtReader.GetAttribute("value")
If Not strstrNameAttribute Is Nothing Then
If strstrNameAttribute.ToLower() = StrNodeKeyName.ToLower() Then
Exit While
End If

Else
strValueArrtibute = ""
End If
End If
End While
XTReader.Close()
Return strValueArrtibute
Catch ex As Exception
Throw ex
End Try
Return Nothing
End Function



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
To read a XML file in 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: To create a Excel file in vb.net
Previous Resource: Execute a new microsoft word
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use