I’m having a little issue reading an XML file…
Let’s say that I have a XML file like this:
<?xml version=”1.0″ encoding=”UTF-8″?>
<channel>
<item>
<tag1>….</tag1>
<tag2>….</tag2>
<tag3>….</tag3>
<[COLOR=”Red”]specialtag[COLOR=”Purple”]url
<[COLOR=”Red”]specialtag[COLOR=”Purple”]url
</item>
</channel>
Well, I want to get access to the url in the “specialtag” with the .jpg extension. I would think that you have to reference the “specialtag”, save it to variable/object, and loop through the variable because it would be an array…but for some reason this isn’t correct…
what I have so far is this:
[code=php]
$image_location;
$img_count=0;
$enclosure_tags = $item -> enclosure;
foreach ($enclosure_tags as $tag){
$all_attributes = $tag -> attributes();
foreach ($all_attributes as $a => $b){
if ( ($a==”url”) && (preg_match(“/(.jpg)(.)*||(.png)(.)*/i”, $b)) )
{
if ($img_count == 0){
$image_location=$b;
$img_count++;
}
}
}
}
..where “enclosure” would represent “specialtag”…
when I reference $item -> enclosure, I’m not getting an array…
why is that?