==== Books.xml ====
<Books> <Book> <ID>01</ID> <Name>LINQ따라하기</Name> <Type>IT</Type> </Book> <Book> <ID>02</ID> <Name>MVC게시판</Name> <Type>IT</Type> </Book> <Book> <ID>03</ID> <Name>jQuery게시판</Name> <Type>IT</Type> </Book> </Books>
// XElement.Parse("<Books><Book>...</Books>"); XElement countries = XElement.Load(Server.MapPath("Books.xml"));
// 방법1 var countriesWithPhNoFormat = from c in countries.Elements() where c.Element("Name") != null
&& (string)c.Element("Name").Value != "" select c;
// 방법2 var countriesWithPhNoFormat2 = from c in countries.Elements() where c.Descendants("Name") != null
&& (string)c.Descendants("Name").First().Value != "" select c;
'★Dev★ > Linq' 카테고리의 다른 글
[Linq] QueryOperator - Where (0) | 2014.12.06 |
---|---|
[Linq] QueryOperator - OrderBy (0) | 2014.11.26 |
[Linq] QueryOperator - Single (0) | 2014.11.26 |
[Linq] QueryOperator - Select / SelectMany (0) | 2014.11.25 |