本文介绍了c#从xml中获取cant元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做youtube请求,我得到xml流结果我将streamResult

传递给Xdocument,我设法将所有带有spance名称的参数都这样:



 durations = doc.Descendants(xmlNameSpace +content)....... 



但是我发布的已发布元素值是xml:



< feed xmlns = http://www.w3.org/2005/Atom\".......> 
< id> http://gdata.youtube.com/feeds/api/videos< / id>
< updated> 2014-07-15T11:19:24.176Z< / updated>
< category scheme =http://schemas.google.com/g/2005#kind>
< link rel =http://schemas.google.com/g/2005#feedtype =application / atom + xmlhref =http://gdata.youtube.com/feeds/ api / videos/>
- < author>
< name> YouTube< / name>
< uri> http://www.youtube.com/< / uri>
< / author>
< generator version =2.1uri =http://gdata.youtube.com> YouTube数据API< / generator>
< openSearch:totalResults> 125170< / openSearch:totalResults>
< openSearch:startIndex> 1< / openSearch:startIndex>
< openSearch:itemsPerPage> 25< / openSearch:itemsPerPage>
- < entry>
< id> http://gdata.youtube.com/feeds/api/videos/GIk6kSdeIsA< / id>
< Published> 2011-09-21T10:31:53.000Z< / published>
< updated> 2014-07-14T23:05:54.000Z< / updated>
.....< entry>





i托盘此代码maby:

列表与LT;&的XElement GT; node = doc.Root.Descendants(entry)。ToList(); 





请helppp:)

解决方案

i do youtube request and i get the xml stream result i pass the "streamResult"
to "Xdocument" , I managed to take all the parameters with the name spance like this :

durations = doc.Descendants(xmlNameSpace + "content").......


but the "published" element value i cant take this is the xml:

<feed xmlns="http://www.w3.org/2005/Atom".......>
  <id>http://gdata.youtube.com/feeds/api/videos</id>
  <updated>2014-07-15T11:19:24.176Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind">
  <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos" />
- <author>
  <name>YouTube</name>
  <uri>http://www.youtube.com/</uri>
  </author>
  <generator version="2.1" uri="http://gdata.youtube.com">YouTube data API</generator>
  <openSearch:totalResults>125170</openSearch:totalResults>
  <openSearch:startIndex>1</openSearch:startIndex>
  <openSearch:itemsPerPage>25</openSearch:itemsPerPage>
- <entry>
  <id>http://gdata.youtube.com/feeds/api/videos/GIk6kSdeIsA</id>
  <published>2011-09-21T10:31:53.000Z</published>
  <updated>2014-07-14T23:05:54.000Z</updated>
  .....<entry>



i tray this code maby:

List<XElement> node = doc.Root.Descendants("entry").ToList();



please helppp :)

解决方案


这篇关于c#从xml中获取cant元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 09:19
查看更多