How to filter an empty XML element using LinQ in WinRT?

nathanjefferson

New Member
What I want
retrieve task whch "due" element is overdue. What the XML is\[code\]<?xml version="1.0" encoding="utf-8" standalone="yes"?><tasks> <task> <title>11111</title> <due>2012/06/18</due> </task> <task> <title>2121211212</title> <due></due> </task></tasks>\[/code\]What I code
\[code\] var res = from q in xml.Root.Descendants("task") where q.Element("due").IsEmpty == false & (Convert.ToDateTime(q.Element("due").Value)).Date < DateTime.Now.Date select q\[/code\]What the error is\[quote\] An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code \[quote\] Additional information: String was not recognized as a valid DateTime. If there is a handler for this exception, the program may be safely continued. \[/quote\]\[/quote\]-_-
If I delete the task which element"due" is empty, the error went away.
but Don't I just filter the empty element with the code below?!\[code\]q.Element("due").IsEmpty == false\[/code\]Why and how to solve it?
 
Back
Top