Friday, September 26, 2014

how to read and get value of attributes in string xml using vb.net

If you are using net framework 3.5+, you can use linq-to-xml:


1) Use XDocument's Load method to load the whole xml conent.


2) Use Root property and use Element to specify the element you wanna search for.


3) Then use XElement's Attributes and do a loop:


4) Example:



Dim xmlDoc As XDocument = XDocument.Load("XMLFile1.xml")
Dim attributes = From attr In xmlDoc.Root.Element("Pass").Attributes()
Select attr

For Each attr In attributes
Console.WriteLine(attr.Name.ToString() & "<===>" & attr.Value)
Next



ASP.NET Forum

Other Discussion Forums

FreeRice Donate

Issues to report

Free Tech Books Search and Download


No comments:

Post a Comment