Bastiflew
Bastiflew

Reputation: 1166

How to get a value from a child node using a dataset

I use a dataset for reading a XML

ds.ReadXML(steam);

My XML look like this :

<models.Client>
    <id>1</id>
    <libelle>test</libelle>
    <nbSite>0</nbSite>
    <cabinet>false</cabinet>
    <clinique>false</clinique>
    <irm>0</irm>
    <scanner>0</scanner>
    <adresse>
        <id>1</id>
        <ligne1>1, rue toto</ligne1>
        <ligne2 />
        <codePostal />
        <ville />
        <coordonnee>
            <id>1</id>
            <telephone />
        </coordonnee>
    </adresse>
</models.Client>

How I can get the "ligne1" value ? for "libelle", I get the value this way : ds.Tables[0].Rows[0]["libelle"].ToString(); and it's ok, but "ligne1" is a child of models.Client.

thanks

Upvotes: 1

Views: 1533

Answers (1)

Ta01
Ta01

Reputation: 31610

It will be the second (index = 1) datatable, so:

ds.Tables[1].Rows[0]["ligne1"].ToString();

which will print: 1, rue toto

Upvotes: 2

Related Questions