phybnvtsev
New Member
I'm trying to query this xml:\[code\]<pageMap> <pageMapNode id="8039CE09-E7DA-47E1-BCEC-DF96B5E411F4"> <pageMapNode id="79DC0E8A-82F1-47DF-836E-099665A7D2E3"></pageMapNode> <pageMapNode id="3B79FAAC-EB2D-41AC-A91E-12541D0EB377"> <pageMapNode id="170A9FC3-C03E-4088-AC5E-93AA038E0114"></pageMapNode> </pageMapNode> </pageMapNode> <pageMapNode id="A34CADA7-317D-405C-8E8F-DB113F40407F"></pageMapNode></pageMap>\[/code\]Here's my function:\[code\]protected string GetParent(Guid nodeId){ XDocument doc = XDocument.Parse(GetXml()); // parses xml displayed above // returns the 5 page map nodes displayed above IEnumerable<XElement> nodes = doc.Descendants("pageMapNode"); // error: "Sequence contains no elements" XElement node = doc.Descendants("pageMapNode") .Where(n => n.Attribute("id").ToString().ToLower() == nodeId.ToString().ToLower()).Single(); ...}\[/code\]The nodeId parameter I'm passing in is correct - I should get a match, so I don't know why it's returning an error.Anyone see what I'm doing wrong?