XML Reader
Posted: Mon Mar 07, 2011 10:00 am
Hello,
I'm going to learn how to make an easy XML reader:
XML file
Xml Writer Tutorial
I'm going to learn how to make an easy XML reader:
XML file
Code: Select all
Then first of all make sure u put:
<products>
<product>
<id>1</id>
<name>Ipod Touch 4</name>
<price>200</price>
<btw>21</btw>
</product>
<product>
<id>2</id>
<name>Itunes Store Card €15</name>
<price>15</price>
<btw>21</btw>
</product>
</products
Code: Select all
at the top then dim the document and a node:
Imports System.XML
Code: Select all
Then we are going to load the document:
Dim XmlDoc As New XmlDocument
Dim XmlNode As XmlNode
Code: Select all
then for example if the form load it must give each Product in a listbox then do:
XmlDoc.load("Products.xml")
Code: Select all
then if you want more details example like the MMDC6 u can show up a new form and give details:
For Each XmlNode In XmlDoc.SelectNodes("//product")
ListBox1.Items.Add(XmlNode.SelectSingleNode("name").InnerText
Next)
Code: Select all
Project Source:
Greeets Kieken XmlNode = XmlDoc.SelectSingleNode("/products/product[name='" & Form1.ListBox1.SelectedItem & "']")
Label1.Text = XmlNode.SelectSingleNode("id").InnerText
Label2.Text = XmlNode.SelectSingleNode("name").InnerText
Label3.Text = XmlNode.SelectSingleNode("price").InnerText & " EUR"
Label4.Text = XmlNode.SelectSingleNode("btw").InnerText & " %"

Xml Writer Tutorial