The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: why the XML loading into flash but not html??

  1. #1

    why the XML loading into flash but not html??

    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:
    Code:
    <?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 Code:
    <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[i].getElementsByTagName("comments")[0].childNodes[0].nodeValue);
    document.write("</td>");
    
    document.write("<td>");
    document.write(
    x[i].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>
    <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>[/HTML]

    and im using the load xml tutorial from here: http://www.flash-db.com/Tutorials/loading/ like so -

    Code:
    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[i].attributes.name
    			subnodes = nodes[i].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

  2. #2
    1,839
    posts
    Registered User
    look into the simplexml object...Ive found that to be awesome for php

    [edit] nm your using JS and asp...dunno how to do that

  3. #3
    thanks joran ill look into the simplexml object.. and yeah, im not adverse to using some php if thats an route to go down

    and as for your mention of asp code - i cant see any anywhere in that code i presented earlier =/ - but then i dont program with it so wouldnt use it knowingly.

  4. #4
    1,839
    posts
    Registered User
    i just assumed on the ASP...since you were doing it with JS...

    I would look into simplexml if you can use php....I struggled with xml for a long time until i figured that one out (its a built in thing in php 5...maybe php4)

    but it makes reading nodes easy...makes reading attributes easy makes manipulating nodes easy and makes writing XML easy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012