Selecting a tree by its attribute in an XML file read into a DataSet

  • Thread starter ~~~ .NET Ed ~~~
  • Start date
N

~~~ .NET Ed ~~~

Hi,
I am reading the attached XML file into a DataSet and that is so far OK.
The problem is that I need to select a tree by its attribute (the Country
node tree whose code attribute is XYZ) so that the selected child nodes (of
the selected tree) are then bound to a DropDownList. I am afraid I haven't
done that so I do not know how to do that.
I think the code below simply gets all Country nodes, but I need to select
only the one with a matching country code

Sample code:
DataSet dsProvinces = new DataSet("Country");
dsProvinces.ReadXmlSchema(schemaFile); // schema was generated in
VS.NET from XML file
dsProvinces.ReadXml(file);
this.DropDownListProvince.DataSource = dsProvinces;
this.DropDownListProvince.DataMember = "Country";

Sample XML file:
<?xml version="1.0" encoding="utf-8"?>

<ProvinceList xmlns="http://localhost/CyberRealty/backend/Provinces.xsd">

<Country code="BE" name="Belgium">

..... some other nodes

</Country>

<Country code="NL" name="Netherlands">

<Province id="DR">Drenthe</Province>

<Province id="FV">Flevoland</Province>

<Province id="FR">Friesland</Province>

<Province id="GE">Gelderland</Province>

<Province id="GR">Groningen</Province>

<Province id="LI">Limburg</Province>

<Province id="NB">Noord Brabant</Province>

<Province id="NH">Noord Holland</Province>

<Province id="OI">Overijssel</Province>

<Province id="UT">Utrecht</Province>

<Province id="ZE">Zeeland</Province>

<Province id="ZH">Zuid Holland</Province>

</Country>

</ProvinceList>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top