Hi there…
i have got this scripts which load dynamic text from xml file and it work fine:
Actionscript:
// The first step is to activate the XML object
headlineXML = new XML();
/*
With the XML Object now active you must now load an XML foramtted document.
Any DTD or XLS formatting will be ignored.
*/
headlineXML.onLoad = myLoad;
headlineXML.load("headline.xml");
// Before proceeding to far into the program, make sure the XML document has loaded
// Extract information from the XML file
function myLoad(ok) {
if (ok == true) {
Publish(this.firstChild);
}
}
function Publish(HeadlineXMLNode) {
if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
content = "";
story = HeadlineXMLNode.firstChild;
while (story != null) {
if (story.nodeName.toUpperCase() == "STORY") {
lead = "";
body = "";
URL = "";
element = story.firstChild;
while (element != null) {
if (element.nodeName.toUpperCase() == "LEAD") {
lead = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "BODY") {
body = element.firstChild.nodeValue;
}
if (element.nodeName.toUpperCase() == "URL") {
URL = element.firstChild.nodeValue;
}
element = element.nextSibling;
}
content += "<font size='+2' color='#3366cc'><a href='"+URL+"'>"+lead+"</a></font><br>"+body+"<br><br>";
txt.htmltext=content;
}
story = story.nextSibling;
}
}
}
XML CODE
<broadcast>
<story>
<lead>This is Headline 1</lead>
<body>This is where you can add content that will appear under the first headline</body>
<URL>http://www.communitymx.com/</URL>
</story>
<story>
<lead>This is Headline 2</lead>
<body>This is content that can appear under the second headline.</body>
<URL>http://www.flash-remoting.com/</URL></story>
<story>
<lead>This is Headline 3</lead>
<body>This is content that can appear under the third headline.</body>
<URL>http://www.macromedia.com/</URL>
</story>
</broadcast>
But i wanted to connect with PHP with outputing PHP file as xml code. And when i try to load this events.php file using AS , it doesnt work… Please help.
events.php
<?
require('site-includes.php');
$results = get_Events();
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<broadcast>
";
for($x=0; $x<count($results); $x++)
{
$xml_output .= " <story>
";
$xml_output .= " <lead>".$results[$x]['date']."</lead>
";
$xml_output .= " <body>".$results[$x]['title']."</body>
";
$xml_output .= " <URL>events-detail.php?id=".$results[$x]['id']."</URL>
";
$xml_output .= " </story>
";
}
$xml_output .= "</broadcast>";
header("Content-type: text/xml");
echo $xml_output;
?>