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

Discussion in 'ASP .Net' started by ~~~ .NET Ed ~~~, Mar 7, 2005.

  1. 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>
    ~~~ .NET Ed ~~~, Mar 7, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,096
  2. Stefan_W
    Replies:
    1
    Views:
    8,163
    Stefan_W
    Nov 5, 2008
  3. thunk
    Replies:
    1
    Views:
    294
    thunk
    Mar 30, 2010
  4. thunk
    Replies:
    0
    Views:
    458
    thunk
    Apr 1, 2010
  5. thunk
    Replies:
    14
    Views:
    606
    thunk
    Apr 3, 2010
Loading...

Share This Page