associate989
New Member
I can't seem to find an article with this same problem.I have an XML file like this:\[code\]<user id="" name="" termsofuse="http://boardgamegeek.com/xmlapi/termsofuse"><firstname value="" /> <lastname value="" /> <avatarlink value="http://stackoverflow.com/questions/12745729/N/A" /> <yearregistered value="" /> <lastlogin value="http://stackoverflow.com/questions/12745729/2012-10-04" /> <stateorprovince value="" /> <country value="" /> <webaddress value="" /> <xboxaccount value="" /> <wiiaccount value="" /> <psnaccount value="" /> <battlenetaccount value="" /> <steamaccount value="" /> <traderating value="http://stackoverflow.com/questions/12745729/363" /> </user>\[/code\]And I am using the following code to extract the data:\[code\]static string QueryTheData(XDocument doc){ var data = http://stackoverflow.com/questions/12745729/from item in doc.Descendants("user") select new { avatarlink = item.Element("avatarlink").Value, lastlogin = item.Element("lastlogin").Value, }; var t = ""; foreach (var p in data) t += p.ToString(); return t;}\[/code\]But my values returned are null. I'm wondering if it's because the XML file begins:\[code\]<user id="" name="" termsofuse="http://boardgamegeek.com/xmlapi/termsofuse">\[/code\]Whereas in all the examples I have found the XML begins like this:\[code\]<user> ... etc\[/code\]How can I read these values in this format?