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>
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>