Ben harici bir kaynaktan bir veri dosyasını ayrıştırmak için SimpleXML kullanıyorum. Şöyle sonucu, bir küçük resim çekmeye çalışıyorum:
<entry>
<title>Ball_Punch</title>
<author>
<name>burningcandle2010</name>
<uri>https://www.mochimedia.com/community/profile/burningcandle2010</uri>
</author>
<link href="http://www.mochimedia.com/games/allout-offsite" rel="alternate" />
<link href="http://games.mochiads.com/c/g/allout-offsite/Ball_Punch.swf" rel="enclosure" type="application/x-shockwave-flash" />
<id>urn:uuid:bf720e45-7ca0-34c7-a63a-0f6f20a4c267</id>
<media:player height="470" url="http://games.mochiads.com/c/g/allout-offsite/Ball_Punch.swf" width="798" />
<media:thumbnail height="100" url="http://thumbs.mochiads.com/c/g/allout-offsite/_thumb_100x100.png" width="100" />
<media:title>Ball_Punch</media:title>
<media:description>punch your ball</media:description>
<media:keywords>other, rhythm</media:keywords>
<category term="Puzzles" />
<updated>2010-07-04T08:13:22.571963-08:00</updated>
<published>2010-07-04T06:58:55.577826-08:00</published>
<summary type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://www.mochimedia.com/games/allout-offsite">
<img class="thumbnail" src="http://thumbs.mochiads.com/c/g/allout-offsite/_thumb_100x100.png" />
</a>
<dl>
<dt>Tag</dt>
<dd class="tag">cdb41e529fbe39bd</dd>
<dt>Description</dt>
<dd class="description">punch your ball</dd>
<dt>Resolution</dt>
<dd class="resolution">798x470</dd>
<dt>Instructions</dt>
<dd class="instructions" />
<dt>Key Mappings</dt>
<dd class="key_mappings" />
<dt>Control Scheme</dt>
<dd class="control_scheme">{"fire": "left_mouse", "jump": "space", "movement": "mouse"}</dd>
<dt>Categories</dt>
<dd class="categories">Puzzles</dd>
<dt>Keywords</dt>
<dd class="keywords">other, rhythm</dd>
<dt>Rating</dt>
<dd class="rating">Everyone</dd>
<dt>Leaderboards</dt>
<dd class="leaderboards">False</dd>
<dt>Embed</dt>
<dd>
<code class="embed"><embed src="http://games.mochiads.com/c/g/allout-offsite/Ball_Punch.swf" menu="false" quality="high" width="798" height="470" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></code>
</dd>
<dt>Slug</dt>
<dd class="slug">allout-offsite</dd>
<dt>Featured</dt>
<dd class="recommended">False</dd>
<dt>Zip File</dt>
<dd class="zip_url">http://games.mochiads.com/c/g/allout-offsite.zip</dd>
<dt>SWF file size</dt>
<dd class="swf_file_size">184374</dd>
</dl>
</div>
</summary>
</entry>
Benim kodu burada:
$thumbnail = $game->summary->div->a->img->attributes()->src;
Ben print_r ($ resim) ile bu çalıştırdığınızda Ancak, ben alıyorum:
SimpleXMLElement Object
(
[0] => DATA_I_WANT
)
Ne olursa olsun ben ne, bu her zaman ya da boş bir SimpleXMLElement Object olmak rüzgarlar. Ben boşuna ->src[0], ->src->{'0'}
, vb denedim.