Find Elements by Attribute using XDocument

Posted by Ignacio on Stack Overflow See other posts from Stack Overflow or by Ignacio
Published on 2010-04-20T20:05:13Z Indexed on 2010/04/20 20:23 UTC
Read the original article Hit count: 264

Filed under:
|
|
|

This query seems to be valid, but I have 0 results.

IEnumerable<XElement> users =
            (from el in XMLDoc.Elements("Users")
             where (string)el.Attribute("GUID") == userGUID.ToString()
             select el);

My XML is as follows:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Users>
  <User GUID="68327fe2-d6f0-403b-a7b6-51860fbf0b2f">
    <Key ID="F7000012ECEAD101">
      ...
    </Key>
  </User>

</Users>

Do you have any clues to shed some light onto this?

© Stack Overflow or respective owner

Related posts about xdocument

Related posts about c#