SimpleXMLElement Can't Find Node Attribute - php

One entry of the feed:-
<entry>
<id>tag:blogger.com,1999:blog-8729980629780635785.post-7267854162055446813</id>
<published>2015-08-12T10:51:00.000-04:00</published>
<updated>2015-08-12T10:51:07.914-04:00</updated>
<category scheme="http://www.blogger.com/atom/ns#" term="Cancer Prevention" />
<category scheme="http://www.blogger.com/atom/ns#" term="Cervical Cancer" />
<category scheme="http://www.blogger.com/atom/ns#" term="curcumin" />
<category scheme="http://www.blogger.com/atom/ns#" term="HPV" />
<category scheme="http://www.blogger.com/atom/ns#" term="Mouth Cancer" />
<category scheme="http://www.blogger.com/atom/ns#" term="STD" />
<category scheme="http://www.blogger.com/atom/ns#" term="Throat Cancer" />
<category scheme="http://www.blogger.com/atom/ns#" term="Tonsil Cancer" />
<category scheme="http://www.blogger.com/atom/ns#" term="turmeric" />
<title type="text">Curcumin May Prevent HPV-Related Cancers</title>
<content type="html"><h2>Maylin Rodriguez-Paez RN</h2><a href="http://3.bp.blogspot.com/-dPF4cftq7l8/VctX0J56YyI/AAAAAAAAEXo/yHPgb0E_Ha8/s1600/trun.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="167" src="http://3.bp.blogspot.com/-dPF4cftq7l8/VctX0J56YyI/AAAAAAAAEXo/yHPgb0E_Ha8/s1600/trun.jpg" width="320" /></a>HPV is the most common sexually transmitted disease in the United States. It infects at least fourteen million annually and most are unware of their infection status.<sup>1</sup><br /><br />For the most part, HPV does not cause any harm to the infected individual. However, in a minority of cases, HPV can lead to the development of mouth, throat, tonsil, and <a href="http://blog.lifeextension.com/2014/04/mushroom-extract-treat-cervical-cancer.html" target="_blank">cervical cancers</a>.<br /><br />Interestingly, a new study shows curcumin may offer help in combating the HPV virus and preventing HPV-induced cancers. The results were published in the online journal, <i>Ecancermedicalscience</i>. <br /><br /><h3>Curcumin Silences Cancer-Causing Genes </h3>Previous studies show curcumin combats multiple types of <a href="http://www.lifeextension.com//Magazine/2011/3/How-Curcumin-Protects-Against-Cancer/Page-01" target="_blank">cancers</a>. Benefits have been seen for cancers of the breast, prostate, pancreas, and colon.<br /><br />For the current study, oral cancer cells infected with the HPV virus were cultivated along with curcumin extract. According to the results of the study, curcumin suppressed the activity of transcription factors (proteins that control the activity of genes) needed for the cancer cells to develop.<sup>2</sup><br /><br />One transcription factor in particular, NF-kB, is known for being involved in cancer development. Curcumin was also shown to silence cancer-promoting genes (oncogenes) and caused HPV infected cells to undergo apoptosis (cell- suicide).<sup>2</sup><br /><br />HPV-related cancers (especially those developing in the throat and mouth) are growing within the United States. Prior research shows curcumin helps to clear the HPV virus from cervical tissue.<sup>3</sup><br /><br />Despite the results of this current study, more research is needed to confirm curcumin’s benefits against HPV-related cancers. <br /><br /><h3>How to Get More Curcumin in Your System</h3>Curcumin is an antioxidant found in the herb turmeric. It gives turmeric its characteristic yellow color.&nbsp; <br /><br />While adding turmeric to food is an excellent idea, it’s actually not the best way to obtain curcumin in your diet. Unfortunately, curcumin is poorly absorbed into the bloodstream.<br /><br />Fortunately, supplementing with a curcumin extract offers a way to increase curcumin levels in the blood. Look for preparations that contain <a href="http://www.lifeextension.com//Magazine/2014/2/Bio-Enhanced-TURMERIC-Compounds-Block-Multiple-Inflammatory-Pathways/Page-01" target="_blank">phospholipids </a>for optimal absorption. <br /><br /><h2>References:</h2><ol><li>Available at: <a href="http://www.cdc.gov/std/hpv/stdfact-hpv.htm">http://www.cdc.gov/std/hpv/stdfact-hpv.htm</a>. Accessed May 4<sup>th</sup>, 2015.&nbsp;</li><li><i>Ecancermedicalscience</i>. 2015 Apr 23;9:525.&nbsp;</li><li><i>Asian Pac J Cancer Prev</i>. 2013;14(10):5753-9.</li></ol><img src="http://feeds.feedburner.com/~r/LifeExtensionBlog/~4/BhZ_UDkx0gc" height="1" width="1" alt=""/></content>
<link rel="replies" type="application/atom+xml" href="http://blog.lifeextension.com/feeds/7267854162055446813/comments/default" title="Post Comments" />
<link rel="replies" type="text/html" href="http://blog.lifeextension.com/2015/08/curcumin-may-prevent-hpv-related-cancers.html#comment-form" title="0 Comments" />
<link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8729980629780635785/posts/default/7267854162055446813" />
<link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8729980629780635785/posts/default/7267854162055446813" />
<link rel="alternate" type="text/html" href="http://blog.lifeextension.com/2015/08/curcumin-may-prevent-hpv-related-cancers.html" title="Curcumin May Prevent HPV-Related Cancers" />
<author>
<name>LifeExtension</name>
<uri>http://www.blogger.com/profile/00252359139805937161</uri>
<email>noreply#blogger.com</email>
<gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" />
</author>
<media:thumbnail
xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-dPF4cftq7l8/VctX0J56YyI/AAAAAAAAEXo/yHPgb0E_Ha8/s72-c/trun.jpg" height="72" width="72" />
<thr:total>0</thr:total>
</entry>
Code:-
<?php
$url = 'http://feeds.feedburner.com/LifeExtensionBlog';
$XmlObject = new SimpleXmlElement( file_get_contents($url) );
foreach($XmlObject->entry as $entry) {
$content = (string) $entry->content[0];
$post_title = (string) $entry->title[0];
$tmp = $entry->xpath('media:thumbnail/#url');
var_dump($tmp);
$image_url = (string) $tmp;
echo 'THE IMAGE:' . $image_url . "<br><hr><br>";
echo $post_title . "<br>";
echo $content . "<br>";
}
Output:-
Warning: SimpleXMLElement::xpath(): Undefined namespace prefix in C:\wamp\www\test-4.php on line 20
Title and the content prints fine.

Related

How to parse XML's <media:text type="html"> with PHP

I would be happy if there was someone who can tell me how to decode the following string from XML to PHP:
<media:text type="html">
<p>
<a href="foo.com">
<img src="foo.com/foo.jpg" align="left" alt="Foo title" title="Foo title" border="0" />
</a>
</p>
</media:text>
which is part of the following item:
<item>
<title>Foo title</title>
<description>Foo Description</description>
<link>foo.com</link>
<pubDate>Tue, 02 Feb 2021 18:23:51 EST</pubDate>
<media:content url="foo.com/foo.jpg" />
**<media:text type="html">
<p>
<a href="foo.com">
<img src="foo.com/foo.jpg" align="left" alt="Foo title" title="Foo title" border="0" />
</a>
</p>
</media:text>**
</item>
With the code portion
$ content = $ xml-> channel-> item [$ i] -> children ('media', True) -> content-> attributes ();
I can only value content but I can't extract
<media: text type = "html">
Thanks to those who can help me!
You can use the SimpleXMLElement function to parse your XML, you will receive an array which will be easily parsed.
See https://www.php.net/manual/fr/simplexml.examples-basic.php.

Determine the $Number of segments of a DASH Media from MPD file

How can I determine the $Number of segments of a DASH media if the MPD file doesn't have any segment URL's lists?
It only has a segment template tag, so I don't know how many segments the media associated to this MPD has.
Hereafter the MPD file:
<?xml version="1.0" encoding="UTF-8" ?>
<MPD profiles="urn:mpeg:dash:profile:isoff-live:2011" type="dynamic" availabilityStartTime="2017-09-24T02:32:58Z" minimumUpdatePeriod="PT2.0S" minBufferTime="PT1S" timeShiftBufferDepth="PT2M" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd">
<Period start="PT0S">
<AdaptationSet mimeType="video/mp4" startWithSAP="1" segmentAlignment="true">
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" />
<ContentProtection schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
<mas:MarlinContentIds xmlns:mas="marlin:mas:1-0:services:schemas:mpd" >
<mas:MarlinContentId>urn:marlin:kid:48e495a75aefaa2f22a8c15f8c564afa</mas:MarlinContentId>
</mas:MarlinContentIds>
</ContentProtection>
<SegmentTemplate timescale="10000000" presentationTimeOffset="311133404" duration="20000000" startNumber="1" media="$RepresentationID$_Segment-$Number$.m4v" initialization="$RepresentationID$_init.m4i" />
<Representation width="1920" height="1080" frameRate="25" codecs="avc1.640029" scanType="progressive" id="Stream_0_1600000" bandwidth="1600000" />
<Representation width="1920" height="1080" frameRate="25" codecs="avc1.640029" scanType="progressive" id="Stream_1_2600000" bandwidth="2600000" />
<Representation width="1920" height="1080" frameRate="25" codecs="avc1.640029" scanType="progressive" id="Stream_2_3900000" bandwidth="3900000" />
<Representation width="1920" height="1080" frameRate="25" codecs="avc1.640029" scanType="progressive" id="Stream_3_4800000" bandwidth="4800000" />
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" startWithSAP="1" lang="ita" segmentAlignment="true">
<ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" />
<ContentProtection schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
<mas:MarlinContentIds xmlns:mas="marlin:mas:1-0:services:schemas:mpd" >
<mas:MarlinContentId>urn:marlin:kid:48e495a75aefaa2f22a8c15f8c564afa
</mas:MarlinContentId>
</mas:MarlinContentIds>
</ContentProtection>
<SegmentTemplate timescale="10000000" presentationTimeOffset="311133404" duration="20000000" startNumber="1" media="$RepresentationID$_Segment-$Number$.m4a" initialization="$RepresentationID$_init.m4i" />
<Representation audioSamplingRate="48000" codecs="mp4a.40.5" id="Stream_4_96000" bandwidth="96000" />
</AdaptationSet>
</Period>
</MPD>
I have difficult to understand how the next segment $Number is calculated.
For live manifests, you have to calculate the approximate segment number based on the start time of the event, i.e. calculate the elapsed duration (time since the beginning of the event) till now (wall clock time - start time). Divide that by the fixed duration of each segment.
Because the startNumber=1, we can get the most recent segment number by calculating startNumber + (elapsedDur/segmentDur).
IMHO, this is nice way of keeping small manifest size. But this expects the DASH client to have its clock synchronized. Otherwise you will end up requesting segment numbers that do not exist (either too early or late). You will also run into a lot of 404s if the segments are not advertised yet.

Xpath query in PHP to attribute from element with specific attribute value

I'm truly bending my head over something that should be way to simple. I have an XML feed with 25 entries in the root. I'm already iterating them as $entry in PHP.
Here is an example of one entry in the xml feed:
<entry>
<id>tag:blogger.com,1999:blog-7691515427771054332.post-4593968385603307594</id>
<published>2014-02-10T06:33:00.000-05:00</published>
<updated>2014-02-10T06:40:34.678-05:00</updated>
<category scheme="http://www.blogger.com/atom/ns#" term="Aurin" />
<category scheme="http://www.blogger.com/atom/ns#" term="fan art" />
<category scheme="http://www.blogger.com/atom/ns#" term="Fred-H" />
<category scheme="http://www.blogger.com/atom/ns#" term="spellslinger" />
<category scheme="http://www.blogger.com/atom/ns#" term="wildstar" />
<title type="text">Fan Art Showcase: She's gunnin' for trouble!</title>
<content type="html">Some random content</content>
<link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7691515427771054332/posts/default/4593968385603307594" />
<link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7691515427771054332/posts/default/4593968385603307594" />
<link rel="alternate" type="text/html" href="http://www.wildstarfans.net/2014/02/fan-art-showcase-shes-gunnin-for-trouble.html" title="Fan Art Showcase: She's gunnin' for trouble!" />
<author>
<name>Name Removed</name>
<uri>URL removed</uri>
<email>noreply#blogger.com</email>
<gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-ow-dvUDbNxI/AAAAAAAAAAI/AAAAAAAABTY/MhrybgagMv0/s512-c/photo.jpg" />
</author>
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Ifp6awhDJuU/UWQEUl8nhUI/AAAAAAAABss/BSZ_YYM1U38/s72-c/fan-art-header.png" height="72" width="72" />
</entry>
I want to get the href of the third link with rel set to alternate. The alternate link isn't always the third one. I know how to do this through SimpleXML, but I want to get to know xpath for this, because through simpleXML it's more complicated and with this I hope I'm one step closer to understanding complex xpath queries.
The PHP I got that makes the most sense to me is:
$href = $entry->xpath('link[#rel="alternate"]/#href');
I tried multiple queries based on the information I found, but they all resulted in nothing. Here is a list of the queries I tried:
$href = $entry->xpath('link[#rel="alternate"]/#href/text()');
$href = $entry->xpath('link[#rel="alternate"]')->getAttributes()->href;
$href = $entry->xpath('*[#rel="alternate"]'); $href = $href['href'];
As it turns out from the chat conversation from my original question I had to register the namespace. In the end I used this website and the code turned out to be like this:
$feed = new DOMDocument();
$feed->load("http://www.wildstarfans.net/feeds/posts/default");
$xpath = new DOMXPath($feed);
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
foreach ($xpath->evaluate('//atom:entry') as $entry) {
$href = $xpath->evaluate('string(atom:link[#rel="alternate"]/#href)', $entry);
}
Credits go to ThW and Wrikken. Wish I could give you guys SO points for this.
$href = $entry->xpath('link[#rel="alternate"]');
$href = (string) $href[0]->attributes()->href;

HTML , PHP search box Help

How do i define the search box as VIN , so the value in my search field is sent to the php code $VIN which then retrieves it from the database.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Victorian Car Imports</title>
</head>
<body body bgcolor= "#000000">
<table width="1359" height="1028" border="0" bgcolor="#000000" bg>
<tr>
<td width="111" height="120"><img src="Logo.png" width="111" height="120" /></td>
<td width="1238"><img src="banner.jpg" width="720" height="94" align="middle"/></td>
</tr>
<tr>
<td height="780" valign="top"><a href="index.html">
<img src="Home.png" width="100" height="35" border="0"/></a> <br/> <p>
<img src="cars.png" border="0" width="100" height="35" /> <br/>
<p>
<img src="FAQ.png" border="0" width="100" height="35" /> <br/> <p>
<img src="Order_form.png" width="100" height="35" border="0" /> <p>
<img src="Contact_us.png" width="100" height="35" border="0" /></td>
<td font color= "#FFFFFF" BODY TEXT="#FFFFFF" valign="top" ><font color="#FFFFFF" >
<form name="search" action="http://www.deakin.edu.au/~sjrem/ssss.php" method="post">
<h2> Search for a car of your choice </h2>
<?php
$VIN = $_request ["search"]
?>
<p>
<table border="0">
<tr>
<td><input type="text" name="search" /> </td>
</tr>
</table>
<p>
<input type="submit" name="action" value="search" />
</FORM>
<p>
1) This skyline R32 GTR has a low 22000K's on the clock. It has been taken car of very well. It is a 1992 model which consists of a immaculate interior and a manual gearbox. It comes equipped with Air Conditioner, Alloy Wheels, Power Steering, Power Windows and a stereo system. <p> $22000 Complied
<p>
<p><img src="R32_GTR_Front.jpeg" width="320" height="240" /><img src="R32_GTR_Rear.jpeg" width="320" height="240" />
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/skyline+gt-r/7898243/photo/?sid=300&pn=4 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/skyline+gt-r/7898243/photo/?sid=300&pn=0 -->
<p> 2) As new 2002 Nissan Silvia S15. 15000 Genuine K's with log books. This prestige car, come with Air Conditioner, Alloy Wheels, Power Steering, Power Windows, Turbo. This is a clean unmodified Silvia. Its one of a kind these days. It has been driven by our buyers in Japans, and the all clear has been given. So what are you waiting for? <p> $20000 including on road costs <p>
<img src="Silvia_front.jpeg" width="374" height="294" /><img src="Silvia_rear.jpeg" width="390" height="295" /> <p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/silvia/7896477/photo/?sid=300&pn=1 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan car/nissan/silvia/7896477/photo/?sid=300&pn=0 -->
3) Brand New Nissan Skyline R35 GTR. This GTR is straight from the Nissan Factory in Japan. It is a 3.8 Ltr, Right hand drive, Gun metal grey in colour. It has a manual gearbox with 6 speed control. This performance car has 320kw at all four wheels and with that comes, traction control, abs brakes, driver, passenger and side air bags, power steering, and a alarm system. Contact us, if you would like any more information. $180000 Deliverd to your door step.
<p><img src="R35_front.jpg" width="384" height="284" /><img src="R35_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/nissan+gt-r/7901460/photo/?sid=300&pn=2 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/nissan/nissan+gt-r/7901460/photo/?sid=300&pn=0 -->
4) This 2005 Subaru Impreza arrived last week. It is one of our AWD turbo vechicles. It sports a powerful 180kw, and handles like a dream. The body is staight, and the paint is immaculate. It comes with 12 months rego, $17999
<p><img src="subaru_front.jpg" width="384" height="284" /><img src="subaru_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/subaru/impreza/7904397/photo/?sid=300&pn=4 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/subaru/impreza/7904397/photo/?sid=300&pn=0 -->
5) Mitsubishi Evolution 2006. This car is scheduled to arrive in Victoria in two weeks. It is All wheel drive sports car, sporting a 210 kw engine. It has all the safety features, such as airbags, traction control, ABS brakes, and power steering. This is a car which will never disappoint. $35000 including all on road costs.
<p><img src="mitsubishi_front.jpeg" width="384" height="284" /><img src="mitsubishi_rear.jpeg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/mitsubishi/lancer+evolution+ix+mr/7901029/photo/?sid=300&pn=2 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/mitsubishi/lancer+evolution+ix+mr/7901029/photo/?sid=300&pn=0 -->
6) Toyota Chaser 1996. Boasting many electric features, Power windows, Power mirrors, Heated seats, and HID lights. This is a car, which looks like a normal family car, but has the grunt when the power is needed. We need this car moved fast, due to our next shipment coming in September. Priced to sell! $10 999
<p><img src="chaser_front.jpg" width="384" height="284" /><img src="chaser_rear.jpg" width="360" height="285" />
<p>
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/toyota/chaser/7846594/photo/?sid=300&pn=0 -->
<!-- Reference: http://www.tradecarview.com/used_car/japan%20car/toyota/chaser/7846594/photo/?sid=300&pn=2 -->
</FONT>
</tr>
<tr>
<td width="111" height="120">row 2 cell 3</td>
<td width="1238"><FONT color="#FFFFFF" >©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT104: Introduction to Web Development. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY."</FONT>
</td>
</tr>
</table>
</body>
</html>
first your searchbox:
<input type="text" value="" name="vin" />
then in your php code:
$vin = mysql_real_escape_string($_POST['vin']);
//then do your query with $vin

SimpleXML won't return data properly

I'm using SimpleXML to parse a data file from an external source. I'm trying to pull a thumbnail from the result, which looks like this:
<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>
My code is here:
$thumbnail = $game->summary->div->a->img->attributes()->src;
However, when I run this through print_r($thumbnail), I get:
SimpleXMLElement Object
(
[0] => DATA_I_WANT
)
No matter what I do, it always winds up being this or an empty SimpleXMLElement Object. I've tried ->src[0], ->src->{'0'}, etc. to no avail.
Try simply typecasting to a string:
print_r((string) $thumbnail)
SimpleXML has a habit of being a little shady when you try to actually use the data that it collects. I'm in a habit of just typecasting everything it spits out.
Good luck!
Just cast to a string. :]
$thumbnail = (string)$game->summary->div->a->img->attributes()->src;

Categories