- This topic helps us how to read XML file using vb programming.
- For creating a new XML file in VB.NET, we are using XmlTextWriter class.
- How to create XML file using vb programming?
XML (Extensible Markup Language) – How to create XML file using vb
- Extensible Markup Language (XML) is a markup language created to structure, store, and transport data by defining a set of rules for encoding documents in a format that is both human-readable and machine-readable.
- The design goals of XML emphasize simplicity, generality, and usability over the Internet.
- XML is a textual data format with strong support via Unicode for the languages of the world.
- XML is developed by World Wide Web Consortium.
- Hundreds of XML-based languages have been developed, including RSS, Atom, SOAP, and XHTML.
XmlDataDocument Class – How to read XML file in vb
- XmlDataDocument allows structured data to be stored, retrieved, and manipulated through a relational DataSet.
Namespace: System.Xml
Assembly: System.Data (in System.Data.dll)
- Syntax for XmlDataDocument
|
1 2 3 4 5 6 |
Syntax for XmlDataDocument 'Declaration <ObsoleteAttribute("XmlDataDocument class will be removed in a future release.")> _ <HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True)> _ Public Class XmlDataDocument _ Inherits XmlDocument |
XmlDataDocument.Load Method (XmlReader) – How to read XML file in vb
- XmlDataDocument.Load Method loads the XmlDataDocument from the specified XmlReader.
- Syntax for XmlDataDocument.Load Method (XmlReader)
|
1 2 3 4 |
'Declaration Public Overrides Sub Load ( _ reader As XmlReader _ ) |
XmlDataDocument.GetElementsByTagName Method (String) – How to read XML file in vb
- XmlDataDocument.GetElementsByTagName Method (String) returns an XmlNodeList containing a list of all descendant elements that match the specified Name.
- Syntax for XmlDataDocument.GetElementsByTagName Method (String)
|
1 2 3 4 |
'Declaration Public Overrides Function GetElementsByTagName ( _ name As String _ ) As XmlNodeList |
How to read XML file in vb – Complete Code
|
1 2 3 4 5 6 7 8 9 10 11 12 |
Dim xmldoc As New XmlDataDocument() Dim xmlnode As XmlNodeList Dim i As Integer Dim str As String Dim fs As New FileStream("C:\product.xml", FileMode.Open, FileAccess.Read) xmldoc.Load(fs) xmlnode = xmldoc.GetElementsByTagName("Product") For i = 0 To xmlnode.Count - 1 xmlnode(i).ChildNodes.Item(0).InnerText.Trim() str = xmlnode(i).ChildNodes.Item(0).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(1).InnerText.Trim() & " | " & xmlnode(i).ChildNodes.Item(2).InnerText.Trim() MsgBox(str) Next |
How to read XML file in vb
If you have any suggestions regarding this topic, please contact us…







That isnihgt’s just what I’ve been looking for. Thanks!