I am developing asp.net mobile application. I am using XML as a database. I am querying on the XML to access the required elements & attributes by using LINQ to XML in .
You could just iterate through all the elements and retrieve the attributes for each:
var allDescendants = myElement.DescendantsAndSelf();
var allDescendantsWithAttributes = allDescendants.SelectMany(elem =>
new[] { elem }.Concat(elem.Attributes().Cast<XContainer>()));
foreach (XContainer elementOrAttribute in allDescendantsWithAttributes)
{
// ...
}