如何将XML转换为Xelement?

时间:2013-04-04 10:45:06

标签: xml sharepoint-2007 windows-phone-8 xelement xattribute

string queryText = string.Format(@"<Where>
                <And>    
                <Neq><FieldRef Name='EventType' /><Value Type='recurrence'>3</Value> </Neq> 

                <And>  
                    <Eq><FieldRef Name='fRecurrence'/><Value Type='Recurrance'>True</Value></Eq>
                    <And>  
                      <Geq><FieldRef Name='EndDate' /><Value Type='DateTime'>{0}</Value></Geq>
                      <Leq><FieldRef Name='StartDate' /><Value Type='DateTime'>{0}</Value></Leq> 
                    </And>     
                </And>

            </And>
           </Where> ", new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day).ToString("yyyy-MM-dd"));

这是在sharepoint中使用的类型XmlNode的ndQuery,用于过滤Windows中的GetListItem。想要在WP8中做同样的事情,但它不支持使用XElement的Xml,所以请将此xml转换为XElement。     提前谢谢。

2 个答案:

答案 0 :(得分:0)

只需使用:

var element = XElement.Parse(queryText);

答案 1 :(得分:0)

我的问题解决了。感谢所有有价值的回复。由于sharepoint中的数据不足,会出现上述错误。