Hi again, I am trying to read an XML file in this format;

<?xml version="1.0" encoding="utf-8"?>
<word id="Apple" def="A fruit" />
<word id="Dinosaurs" def="Now Extinct Animal" />
<word id="Giant Panda" def="An Endangered Animal" />
<word id="Asia" def="The Largest Continent" />

I have more than 3000 lines like this. And I want to read the XML file in to two listboxes, Listbox1 will contain the 'id' word and Listbox2 will contain the 'def' word(s) and I have absolutely no idea how to do this, So how am i to do this please?

Recommended Answers

All 2 Replies

this might give you an idea

Imports System.Xml.Linq

		Dim xmlFile As XDocument = XDocument.Load("C:\Users\GeekByChoiCe\Desktop\test.xml")
		Dim _content As IEnumerable(Of XElement) = xmlFile.Root.Elements("word")
		ListBox1.DataSource= (From g In _content Select g.@id).ToList
		ListBox2.DataSource= (From g In _content Select g.@def).ToList
commented: :) +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.