Question

I have come across a problem between an imported RSS feed and an included HTML file containing a set of SVGs wrapped in list items. (HTML with edited SVG excerpt below) Either one or the other displays without a problem. With both included together, the image.html does display the first JPG, but not the SVGs or the PNGs which follow after. I am thinking there is a conflict with the XML(?) I hope that is a clear explanation.

image.html (edited excerpt)>>>

 <li class="layer" data-depth="0.02">
    <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1080 1080">
    <g transform="translate(0 .00002)">
    <path fill="#bababa" d="m.06">    
    </g>
    </svg>    
</li>

PHP (excerpt)>>>

<ul id="scene" class="scene">
    <li class="layer" data-depth="0.0"><img src="/images/lightStudy_8.jpg"></li>
    <?php include('image.html'); ?>
    <li class="layer" data-depth="0.4"><img src="/images/nologo.png"></li>
    <li class="layer" data-depth="0.6"><img src="/images/nologo_white.png"></li>
</ul>

<div class="wrapper">
    <!-- page content -->
    <?php
    $XMLFILE = "http://something/default?alt=rss";
    $TEMPLATE = "http://something/sample-template.html";
    $MAXITEMS = "5";
    include("rss2html.php");
    ?>
</div>
Was it helpful?

Solution

I still have not found the issue causing the conflict which I think has to do with the XML. I work alot with SVG, so I would still like to know the reason so I can avoid problems in the future. However, I am just going to use a method altogether. Not being a whiz at this stuff, I found a parser I could deal with and replaced the HTTP with my own, and the N is just the number of post you wish to display.

Also, {$item['DESCRIPTION']} is the means of pulling out that value from the array. Not knowing how standardized feeds are, I just searched through the XML feed (via browser)to see what tags are used for the info I want to display and followed the syntax.

The source that worked immediately for me is provided below or at: http://www.stemkoski.com/how-to-easily-parse-a-rss-feed-with-php-4-or-php-5/

<?php

//FUNCTION TO PARSE RSS IN PHP 4 OR PHP 4
function parseRSS($url) { 

//PARSE RSS FEED
    $feedeed = implode('', file($url));
    $parser = xml_parser_create();
    xml_parse_into_struct($parser, $feedeed, $valueals, $index);
    xml_parser_free($parser);

//CONSTRUCT ARRAY
    foreach($valueals as $keyey => $valueal){
        if($valueal['type'] != 'cdata') {
            $item[$keyey] = $valueal;
        }
    }

    $i = 0;

    foreach($item as $key => $value){

        if($value['type'] == 'open') {

            $i++;
            $itemame[$i] = $value['tag'];

        } elseif($value['type'] == 'close') {

            $feed = $values[$i];
            $item = $itemame[$i];
            $i--;

            if(count($values[$i])>1){
                $values[$i][$item][] = $feed;
            } else {
                $values[$i][$item] = $feed;
            }

        } else {
            $values[$i][$value['tag']] = $value['value'];  
        }
    }

//RETURN ARRAY VALUES
    return $values[0];
} 


/********************************************************************************************       
**********************
SAMPLE USAGE OF FUNCTION
********************************************************************************************
*********************/

//PARSE THE RSS FEED INTO ARRAY
$xml = parseRSS("http://SomeBlog.com/feeds/posts/default?alt=rss");

//SAMPLE USAGE OF 
$n=1;
foreach($xml['RSS']['CHANNEL']['ITEM'] as $item) {
 if($n<=5) {     
        echo("<article>");  
        echo("<h3 class=\"title\"><a href=\"{$item['LINK']}\" target=\"_blank\">     
{$item['TITLE']}{$link}</a></h3>");
        $pdate = $item['PUBDATE'];
        echo("<h4>".$pdate."</h4>");
        echo("<div class=\"description\">{$item['DESCRIPTION']}</div>");
        echo("</article>");
    }
    $n++;
}

?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top