-5

私は iTunes XML を解析しようとしています:

    <feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>http://itunes.apple.com/us/rss/topSongs/limit=100/genre=24/xml</id> 
  <title>iTunes Store: Top Songs in Reggae</title> 
  <updated>2013-07-09T01:29:02-07:00</updated> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?cc=us&id=27&popId=1" /> 
  <link rel="self" href="http://itunes.apple.com/us/rss/topSongs/limit=100/genre=24/xml" /> 
  <icon>http://itunes.apple.com/favicon.ico</icon> 
- <author>
  <name>iTunes Store</name> 
  <uri>http://www.apple.com/itunes/</uri> 
  </author>
  <rights>Copyright 2008 Apple Inc.</rights> 
- <entry>
  <updated>2013-07-09T01:29:02-07:00</updated> 
  <id im:id="244170">https://itunes.apple.com/us/album/it-wasnt-me/id244192?i=244170&uo=2</id> 
  <title>It Wasn't Me - Shaggy</title> 
  <im:name>It Wasn't Me</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/it-wasnt-me/id244192?i=244170&uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Track" label="Track" /> 
  </im:contentType>
  <category im:id="24" term="Reggae" scheme="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2" label="Reggae" /> 
- <link title="Preview" rel="enclosure" type="audio/x-m4a" href="http://a808.phobos.apple.com/us/r1000/079/Music/v4/38/97/9a/38979a84-c27c-398f-ba65-6c926a76434e/mzaf_3512685345230786148.aac.m4a" im:assetType="preview">
  <im:duration>30000</im:duration> 
  </link>
  <im:artist href="https://itunes.apple.com/us/artist/shaggy/id68616?uo=2">Shaggy</im:artist> 
  <im:price amount="1.29000" currency="USD">$1.29</im:price> 
  <im:image height="55">http://a877.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.55x55-70.jpg</im:image> 
  <im:image height="60">http://a1599.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.60x60-50.jpg</im:image> 
  <im:image height="170">http://a1230.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.170x170-75.jpg</im:image> 
  <rights>℗ 2000 Geffen Records</rights> 
  <im:releaseDate label="August 8, 2000">2000-08-08T00:00:00-07:00</im:releaseDate> 
- <im:collection>
  <im:name>Hot Shot</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/hot-shot/id244192?uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Album" label="Album" /> 
  </im:contentType>
  </im:collection>
  <content type="html"><table border="0" width="100%"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr valign="top" align="left"> <td align="center" width="166" valign="top"> <a href="https://itunes.apple.com/us/album/it-wasnt-me/id244192?i=244170&uo=2"><img border="0" alt="Shaggy - It Wasn't Me artwork" src="http://a1230.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.170x170-75.jpg" /></a> </td> <td width="10"><img alt="" width="10" height="1" src="http://r.mzstatic.com/images/spacer.gif" /></td> <td width="95%"> <b><a href="https://itunes.apple.com/us/album/it-wasnt-me/id244192?i=244170&uo=2">It Wasn't Me</a></b><br/> <a href="https://itunes.apple.com/us/album/hot-shot/id244192?uo=2">Hot Shot</a><br/> <a href="https://itunes.apple.com/us/artist/shaggy/id68616?uo=2">Shaggy</a> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> <br/> <b>Genre:</b> <a href="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2">Reggae</a> <br/> <b>Price:</b> $1.29 <br/> <b>Release Date:</b> August 8, 2000 </font> </td> </tr> </table> </td> </tr> <tr> <td> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> &#169; ℗ 2000 Geffen Records</font> </td> </tr> </table></content> 
  </entry>
- <entry>
  <updated>2013-07-09T01:29:02-07:00</updated> 
  <id im:id="406647">https://itunes.apple.com/us/album/three-little-birds/id406659?i=406647&uo=2</id> 
  <title>Three Little Birds - Bob Marley</title> 
  <im:name>Three Little Birds</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/three-little-birds/id406659?i=406647&uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Track" label="Track" /> 
  </im:contentType>
  <category im:id="24" term="Reggae" scheme="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2" label="Reggae" /> 
- <link title="Preview" rel="enclosure" type="audio/x-m4a" href="http://a1348.phobos.apple.com/us/r1000/080/Music/fb/f5/cd/mzm.geqleopn.aac.p.m4a" im:assetType="preview">
  <im:duration>30000</im:duration> 
  </link>
  <im:artist href="https://itunes.apple.com/us/artist/bob-marley/id121982?uo=2">Bob Marley</im:artist> 
  <im:price amount="1.29000" currency="USD">$1.29</im:price> 
  <im:image height="55">http://a1459.phobos.apple.com/us/r1000/038/Features/2c/07/84/dj.waxakaco.55x55-70.jpg</im:image> 
  <im:image height="60">http://a181.phobos.apple.com/us/r1000/038/Features/2c/07/84/dj.waxakaco.60x60-50.jpg</im:image> 
  <im:image height="170">http://a1636.phobos.apple.com/us/r1000/038/Features/2c/07/84/dj.waxakaco.170x170-75.jpg</im:image> 
  <rights>℗ 2001 Island Records Inc.</rights> 
  <im:releaseDate label="June 2, 1977">1977-06-02T17:00:00-07:00</im:releaseDate> 
- <im:collection>
  <im:name>Exodus (Remastered)</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/exodus-remastered/id406659?uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Album" label="Album" /> 
  </im:contentType>
  </im:collection>
  <content type="html"><table border="0" width="100%"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr valign="top" align="left"> <td align="center" width="166" valign="top"> <a href="https://itunes.apple.com/us/album/three-little-birds/id406659?i=406647&uo=2"><img border="0" alt="Bob Marley - Three Little Birds artwork" src="http://a1636.phobos.apple.com/us/r1000/038/Features/2c/07/84/dj.waxakaco.170x170-75.jpg" /></a> </td> <td width="10"><img alt="" width="10" height="1" src="http://r.mzstatic.com/images/spacer.gif" /></td> <td width="95%"> <b><a href="https://itunes.apple.com/us/album/three-little-birds/id406659?i=406647&uo=2">Three Little Birds</a></b><br/> <a href="https://itunes.apple.com/us/album/exodus-remastered/id406659?uo=2">Exodus (Remastered)</a><br/> <a href="https://itunes.apple.com/us/artist/bob-marley/id121982?uo=2">Bob Marley</a> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> <br/> <b>Genre:</b> <a href="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2">Reggae</a> <br/> <b>Price:</b> $1.29 <br/> <b>Release Date:</b> June 2, 1977 </font> </td> </tr> </table> </td> </tr> <tr> <td> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> &#169; ℗ 2001 Island Records Inc.</font> </td> </tr> </table></content> 
  </entry>
- <entry>
  <updated>2013-07-09T01:29:02-07:00</updated> 
  <id im:id="33865241">https://itunes.apple.com/us/album/angel/id244192?i=33865241&uo=2</id> 
  <title>Angel - Shaggy & Rayvon</title> 
  <im:name>Angel</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/angel/id244192?i=33865241&uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Track" label="Track" /> 
  </im:contentType>
  <category im:id="24" term="Reggae" scheme="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2" label="Reggae" /> 
- <link title="Preview" rel="enclosure" type="audio/x-m4a" href="http://a880.phobos.apple.com/us/r1000/079/Music/v4/fb/7f/19/fb7f190d-61ab-da98-4b58-0984afcf08ce/mzaf_7385137813188409640.aac.m4a" im:assetType="preview">
  <im:duration>30000</im:duration> 
  </link>
  <im:artist href="https://itunes.apple.com/us/artist/rayvon/id27079?uo=2">Shaggy & Rayvon</im:artist> 
  <im:price amount="1.29000" currency="USD">$1.29</im:price> 
  <im:image height="55">http://a877.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.55x55-70.jpg</im:image> 
  <im:image height="60">http://a1599.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.60x60-50.jpg</im:image> 
  <im:image height="170">http://a1230.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.170x170-75.jpg</im:image> 
  <rights>℗ 2000 Geffen Records</rights> 
  <im:releaseDate label="August 8, 2000">2000-08-08T00:00:00-07:00</im:releaseDate> 
- <im:collection>
  <im:name>Hot Shot</im:name> 
  <link rel="alternate" type="text/html" href="https://itunes.apple.com/us/album/hot-shot/id244192?uo=2" /> 
- <im:contentType term="Music" label="Music">
  <im:contentType term="Album" label="Album" /> 
  </im:contentType>
  </im:collection>
  <content type="html"><table border="0" width="100%"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr valign="top" align="left"> <td align="center" width="166" valign="top"> <a href="https://itunes.apple.com/us/album/angel/id244192?i=33865241&uo=2"><img border="0" alt="Shaggy & Rayvon - Angel artwork" src="http://a1230.phobos.apple.com/us/r1000/046/Features/5c/ef/1e/dj.biwzhgic.170x170-75.jpg" /></a> </td> <td width="10"><img alt="" width="10" height="1" src="http://r.mzstatic.com/images/spacer.gif" /></td> <td width="95%"> <b><a href="https://itunes.apple.com/us/album/angel/id244192?i=33865241&uo=2">Angel</a></b><br/> <a href="https://itunes.apple.com/us/album/hot-shot/id244192?uo=2">Hot Shot</a><br/> <a href="https://itunes.apple.com/us/artist/rayvon/id27079?uo=2">Shaggy &amp; Rayvon</a> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> <br/> <b>Genre:</b> <a href="https://itunes.apple.com/us/genre/music-reggae/id24?uo=2">Reggae</a> <br/> <b>Price:</b> $1.29 <br/> <b>Release Date:</b> August 8, 2000 </font> </td> </tr> </table> </td> </tr> <tr> <td> <font size="2" face="Helvetica,Arial,Geneva,Swiss,SunSans-Regular"> &#169; ℗ 2000 Geffen Records</font> </td> </tr> </table></content> 
  </entry>

.....

この方法では:

XDocument xml = XDocument.Parse(html);

foreach (XElement entryElement in xml.Elements("entry"))
{

}

そして、ループは常に null (繰り返さない) です。何が問題なのですか?

4

1 に答える 1

2

試す:

XDocument xml = XDocument.Parse(html);

foreach (XElement entryElement in xml.Descendants(XName.Get("entry", "http://www.w3.org/2005/Atom")))
{

}
于 2013-07-09T10:36:43.957 に答える