I want to read a Rootnode element attribute value ,but my code is not working.my code
XML:
<Datatable Name="AS1" Type="table">
<Table>
<Column Name="ID" Type="uniqueidentifier">
</Column>
</Table>
</Datatable>
Code:
XDocument doc= XDocument.Load(path);
var q = (from c in doc.Elements("Datatable")
select new
{
dID = c.Attribute("Name"),
}).ToList();
var on = new Ton()
{
Name=q[0].dID.ToString(),
CreateTime = DateTime.Now
};
So i need to pass the selected rootnode attribute value to the Name object.
but when i trying with this code q has return count=0.
can anyone please help to get a rootnode value?
Thanks,
change the start of your code :
… same