Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
I have started to learn XML and write a simple program for getting data from XML file and writes to file.
I have a much line such as: "<dipswitch name="Rack Test (Cheat)">"
How i can get atribuite name by all tags <dipswirch>?
I use standart XML library and my code is now:

VB
Try
       Dim m_xmld As XmlDocument
       Dim m_nodelist As XmlNodeList
       Dim m_node As XmlNode

       m_xmld = New XmlDocument()
       m_xmld.Load("D:\test.xml")
       m_nodelist = m_xmld.SelectNodes("dipswitch")

       For Each m_node In m_nodelist

           MessageBox.Show(m_node.InnerText)

       Next
   Catch errorVariable As Exception

   End Try

Thank you!
Posted

1 solution

Input:
<H>
<H1>
<font>jkhhujhjhj</font>
<size>12</size>
</H1>
</H>


VB
Dim XMLDoc As New XmlDocument()
  Dim nodlist As XmlNodeList
  Dim node As System.Xml.XmlNode
XMLDoc.Load ("C:\path.xml")
 nodlist = XMLDoc.SelectNodes("/H/H1")
     For Each node As System.Xml.XmlNode In nodlist

                    TextBox1.Text = node.ChildNodes.Item(0).InnerText
                    TextBox2.Text = node.ChildNodes.Item(1).InnerText
     Next


Output:
Textbox1.Text=jkhhujhjhj
Textbox2.Text=12
Hope this Will help you to understand abt how to get the values from the xml.......
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900