Ive searched and searched, and cant find an answer. So i turn-eth, to you all.
Im using XML as a database to store newsItems for display on the front page.
I can get everything to display correctly, except for images inside of the content. Im using empty elements in the same format as HTML to keep it simple for those that are going to be actually writing the news items to be displayed.
Here is what i have.
112609.xml-----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xslt.xslt"?>
<newsItem>
<itemTitle>News Is Working!!!</itemTitle>
<itemDate>11-26-2009</itemDate>
<itemContent>[b]<img src="../../images/headerOverlay.jpg" />[/b]This is a test of the news... Blah blah blah.</itemContent>
</newsItem>
handlers.php-------------------------------------------------------------
function getNewsItems(){
$path = 'path/to/xml/dir/';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file !== "." && $file !== ".." && $file !== "xslt.xslt") {
$xml = simpleXML_load_file($path.$file);
$content = $xml->itemContent;
echo "<div id='contentItem'>";
echo "<img src='images/newsItemHeader.png' id='spacer' /><img src='images/newsItemHeader2.png' id='spacer2' />";
echo "<span id='contentHeader'>" . $xml->itemTitle . "</span><span id='date'>" . $xml->itemDate . "</span>";
echo "<div id='contentDetail'>" . $xml->itemContent . "</div></div>";
foreach ($xml->itemContent->children() as $child){
print($child->img);
}
}
}
closedir($handle);
}
}
Please note: handlers.php is included on the front page, which then in turn calls the xml files.
I can get a print_r of $xml to show the img element, but past that, it will not display. If you want to see the output as it stands now, http://www.cohoproductions.org/dev/2010/index.php
That xml file refers to the first news item on the page.
my overall question is how do i get those elements inside itemContent to display on the front page IF they are present? do they have to be named each time i wish to use them? or can i use children() and echo them as they come?
Forgive my terminology if it is not correct, or confusing. Im relatively new at this, and tbh, i dont write php very often.