Link to home
Start Free TrialLog in
Avatar of Cesar Aracena
Cesar AracenaFlag for Argentina

asked on

How do I create a module to parse a XML file and then populate differnt drop down menues?

Hello everybody,

I am very new to XML specially when it comes to software developing. I've work with it before but in web development. A frind of mine asked me to create a program using VB.NET to control his store and I thought that using XML was the best choice because of performance and it's easy to update.

I've created a XML file which holds the items he sells but trully, I don't know how to create a function inside a module to handle that file and then use it to populate different fields (text boxes, combo boxes, etc.) in a form.

The structure I'm using within XML is this:

<?xml version="1.0" encoding="utf-8"?>
<Items>
  <Item>
    <ID>10001</ID>
    <Name>Item 1</Name>
    <Type>Food</Type>
    <Weight>31</Weight>
    <Price>9.99</Price>
  </Item>
  <Item>
    <ID>10002</ID>
    <Name>Item 2</Name>
    <Type>Tool</Type>
    <Weight>700</Weight>
    <Price>39.99</Price>
  </Item>
</NewData>

I would like for example, to be able to display all food items in a grid or whatever, only when the Food cathegory is selected in a dropdown menu.

How can I do this?

Thanks in advance!
Avatar of devlinb
devlinb

You could write the xml file into a dataset then assign the datasource of the grid to this dataset:
Dim ds As New DataSet
ds.WriteXml("C:\filename.xml")
DataGridView1.DataSource = ds

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nmarun
nmarun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Make sure you add this line in your aspx page just below the <%@ Page.. declaration:
<%@ Import Namespace="System.Xml"%>
and
Imports System.Xml
line in the code-behind file.