I was wondering if there is a way to get a list of results into a list with linq for xml. If I had the following xml, for example:
<?xml version="1.0"?> <Sports xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SportPages> <SportPage type="test"> <LinkPage> <IDList> <string>1</string> <string>2</string> </IDList> </LinkPage> </SportPage> </SportPages> </Sports>
How can I get a list of strings from an IDList?
I am new to linq for xml, so I just tried something, I am here now:
var IDs = from sportpage in xDoc.Descendants("SportPages").Descendants("SportPage") where sportpage.Attribute("type").Value == "Karate" select new { ID = sportpage.Element("LinkPage").Element("IDList").Elements("string") };
But the var should randomly read decently. Isn't there a way to get a list of strings from this?
thanks
source share