Im trying to build a Flash site and a basic HTML mirror site. Im wanting both to load from the same XML file (as a ‘news’ section probably).
Anyway, ive found some useful articles and tutorials so im trying to combine them, heres what i have so far:
the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="news.css"?>
<!DOCTYPE data[
<!ELEMENT title (comments, image)>
<!ATTLIST title name CDATA #REQUIRED>
<!ELEMENT comments (#PCDATA)>
<!ELEMENT image (#PCDATA)>
]>
<data>
<title name="News article 1">
<comments>Work wins another new account. But says goodbye to an old one.</comments>
<image>logo1.gif</image>
</title>
<title name="News article 2">
<comments>Another winning account at work. Our boss has announced he is 'jubilant with the whole team'.</comments>
<image>logo2.gif</image>
</title>
</data>
while the HTML - lifted from http://www.w3schools.com/xml/xml_to_html.asp - looks like this:
<html>
<head>
<script language="javascript" type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<script type="text/javascript">
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load("news.xml");
var x=xmlDoc.getElementsByTagName("title");
document.write("<table border='1'>");
for (var i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write(
x*.getElementsByTagName("comments")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write(
x*.getElementsByTagName("image")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
</script>
<br>
<br>
<br>
<span id="moving">Flash not working</span>
<script type="text/javascript" language="javascript">
var so = new SWFObject("load_XML.swf", "moving", "550", "400", "8", "#ffffff");
so.write("moving");
</script>
</body>
</html>
Flash not working
```and im using the load xml tutorial from here: http://www.flash-db.com/Tutorials/loading/ like so -
myXML = new XML()
myXML.ignoreWhite = true
//Load XML file
myXML.load("news.xml")
//Make a reference to current timeline
myXML.ref = this
// Parse XML and fetch
myXML.onLoad = function(succes){
if(succes){
var root = this.firstChild
nodes = root.childNodes
for(var i=0; i<nodes.length; i++) {
this.ref["Title_txt"+i].text = nodes*.attributes.name
subnodes = nodes*.childNodes
this.ref["Comments_txt"+i].text = subnodes[0].firstChild.toString()
this.ref["holder_mc"+i].loadMovie(subnodes[1].firstChild.toString())
}
} else trace("Error loading XML document")
}
stop()
i can get the flash one to work ok, but the HTML one doesnt work - all the HTML code seems to be calling the right (‘title’) nodes from what i can make out… so, can anyone please assist me as to why its not working here, please??
thanks