Friday, 17 April 2015

XML Skip 'wrong' event type



I have a certain BLOATED XML file that i use to generate a Gallery with some few information about the Picture. Besides of the Actual needed NEW there are plenty of entries with OLD, adding more pictures, but creating also duplicate entries.



<result>
<event>
<date>2015-04-14T22:19:02+02:00</date>
<type>OLD</type>
<value1>AAA</value1>
<id>changingIDwhatever</id>
<profile>
<url>/domainpart/SPECIFICNAME/?w=</url>
<name>SPECIFICNAME</name>
<value2>BBB</value2>
<value3>CCC</value3>
<value4>DDD</value4>
<image>
<url>http://ift.tt/1GVEFz7;
<width>320</width>
</image>
</profile>
</event>
<event>
<date>2015-04-14T22:19:02+02:00</date>
<type>NEW</type>
<value1>AAA</value1>
<id>changingIDwhatever</id>
<profile>
<url>/domainpart/ANOTHERNAME/?w=</url>
<name>ANOTHERNAME</name>
<value2>BBB</value2>
<value3>CCC</value3>
<value4>DDD</value4>
<image>
<url>http://ift.tt/1GVEFz7;
<width>320</width>
</image>
</profile>
</event>
<event>
<date>2015-04-14T22:19:02+02:00</date>
<type>NEW</type>
<value1>AAA</value1>
<id>changingIDwhatever</id>
<profile>
<url>/domainpart/SPECIFICNAME/?w=</url>
<name>SPECIFICNAME</name>
<value2>BBB</value2>
<value3>CCC</value3>
<value4>DDD</value4>
<image>
<url>http://ift.tt/1GVEFz7;
<width>320</width>
</image>
</profile>
</event>
</result>


I do generate everything in a pretty neat layout in a very basic way. As i have really NO knowledge at all about php, i usually base on skriptpieces i find that are kind of put together in a way that the outcome mostly is the way i need it.



<?php
//###################Config Start#########################
$memberid = "123456";
$maxAnzahl = 50;
$zaehler = 0;
$baseURL = "http://www.domain.tld";
//###################Config End#########################
$feed = simplexml_load_file('http://ift.tt/1FTGkQ3');
$events = $feed->events;
foreach ($events->event as $event) {
echo "<div class='4u'>";
echo "<article class='box style2'>";
if ($event->type == "newMember") {
echo "<a href='".$baseURL.$event->profile->url.$memberid."' class='image featured' target='_blank'><img src='" . $event->profile->image->url . "' alt='' /> </a>";
} else {
echo "<a href='".$baseURL.$event->profile->url.$memberid."' class='image featured' target='_blank'><img src='" . $event->image->url . "' alt='' /> </a>";
}
echo "<h3><a href='".$baseURL.$event->profile->url.$memberid."'>" . $event->profile->name . "</a></h3>";
echo "</article>";
echo "</div>";
$zaehler = $zaehler + 1;
if ($zaehler == $maxAnzahl) {
break;
}
}
?>


Would be someone able to tell me how i could specify now in that skript how to SKIP all OLD ?


Kind Regards Caylean


No comments:

Post a Comment