Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows Phone 7解析此xml项_Xml_Windows Phone 7_Xml Parsing - Fatal编程技术网

Windows Phone 7解析此xml项

Windows Phone 7解析此xml项,xml,windows-phone-7,xml-parsing,Xml,Windows Phone 7,Xml Parsing,如何使用XDocument解析此图像 <enclosure length="1234" type="image/jpeg" url="http://asd.com/media/picture/1/80/71/3223wee.jpg" /> 我的rss看起来像这样 <item> <title>aaa</title> <desc>aaa</desc> <enclosure length="3234" type=

如何使用XDocument解析此图像

<enclosure length="1234" type="image/jpeg" url="http://asd.com/media/picture/1/80/71/3223wee.jpg" />

我的rss看起来像这样

<item>
 <title>aaa</title>
 <desc>aaa</desc>
 <enclosure length="3234" type="image/jpeg" url="http://asd.com/media/picture/1/80/71/1223wee.jpg" />

</item>

<item>
 <title>aaa</title>
 <desc>aaa</desc>
 <enclosure length="1234" type="image/jpeg" url="http://asd.com/media/picture/1/80/71/3223wee.jpg" />

</item>

aaa
aaa
aaa
aaa
编辑:

正确的工作代码:

            XDocument xdoc = XDocument.Parse(e.Result);
            var data = from query in xdoc.Descendants("item")
                       select new Cikk
                       {
                           Title        = (query.Element("title") == null) ? "" : (string)query.Element("title").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", ""),
                           Description  = (query.Element("description").Value.Equals("")) ? "" : (string)query.Element("description").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", "").Substring(0, 20) + "...",
                           Source       = (query.Element("enclosure") == null) ? "" : (string)query.Element("enclosure").Attribute("url").Value
                       };
XDocument xdoc=XDocument.Parse(e.Result);
var data=来自xdoc.subjects(“项”)中的查询
选择新的Cikk
{
Title=(query.Element(“Title”)==null)?“”:(字符串)query.Element(“Title”).Value.ToString().Replace(“,”),
Description=(query.Element(“Description”).Value.Equals(“”):(string)query.Element(“Description”).Value.ToString().Replace(“,”).Substring(0,20)+“…”,
Source=(query.Element(“enclosure”)==null)?“”:(字符串)query.Element(“enclosure”).Attribute(“url”).Value
};

不太清楚“解析此图像”是什么意思,但您可以轻松获得各个位:

XElement element = /* for example */ item.Element("enclosure");

int length = (int) element.Attribute("length");
string type = (string) element.Attribute("type");
string url = (string) element.Attribute("url");
如果这没有帮助,请澄清你的问题