Xml GetAttribute method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tribal

    #1

    Xml GetAttribute method

    Hi,

    I am trying to access an attribute which is in a nested
    node but I always get a null value.

    Can a nested node have attributes or is just the property
    of a parent node

    <Animals>
    <Dog>
    <Name>Ruff</Name>
    <Attributes Count="2">
    <Value>Bark</Value>
    <Value>Bite</Value>
    </Attributes>
    </Dog>
    </Animals>

    Is the Count attribute valid, if yes how can I access it
    Currently I am trying the following

    xr.ReadStartEle ment("Animals") ;
    while(xr.Read() ) //where xr is pointing to the file
    {
    xr.ReadStartEle ment("Dog");
    string name = xr.ReadElementS tring("Name");
    string count = xr.GetAttribute ("Count"); //gets null
    xr.ReadStartEle ment("Attribute s"); //tried putting
    //above but doesnt work

    .........
    .......
    }

    what am I doing wrong here

    Thanks in advance

    Regards,

    tribal

Working...