C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






To read a XML file in vb.net


Posted Date: 21 Aug 2008    Resource Type: Articles    Category: General

Posted By: D.Jeya kumar(JK)       Member Level: Diamond
Rating:     Points: 10



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
End If
Exit While
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  
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!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use