...

View Full Version : Javascript read in from an xml file and output with write function



stealth_monkey
02-23-2007, 02:27 AM
Javascript read in from an xml file and output with write function

That's the gist of it :)

Hi Guys I'm new here, please go easy on me!

Well you see what I'm trying to do is set up some code that will read in from my xml file (code to follow shortly)

I have the xml file already and it contains information that is read by my flash jukebox.

I'd like to know if it's possible to make that 1 file serve to purposes!

I'm hoping someone can help me understand how I am to achieve this. I have been searching tirelessly for some tutorials relating to this, I found one but I have no idea how to get it to work as it is intended (I'll link that in a minute)

So back to the problem, I want to read in from my xml page using javascript and then using a "javascript write" function, and would like it to display a page, that is the playlist

ok an example of the xml page is here and it is called playlist.xml

<playlist>

<item artist="artist 1" title="track 1" fileType="mp3" path="url/of/track/here" time="0:40"></item>

<item artist="artist 2" title="track 2" fileType="mp3" path="url/of/track/here" time="3:27"></item>

<item artist="artist 3" title="track 3" fileType="mp3" path="url/of/track/here" time="1:40"></item>

<item artist="artist 4" title="track 4" fileType="mp3" path="url/of/track/here"></item>

</playlist>

and a tutorial I found, which I thought sounded just like what I'm looking for can be found here:

http://www.codetoad.com/xml_javascripti_tutorial.asp

I've tried to get that to work, by firstly, creating the javascript file and then also the xml file

I tried initially to set up an alert, just to see if it would work as it is intended. I was hoping that would work, so I could take it a step closer.

But to no avail! :'(

Please, Please, can somebody explain to me how I would achieve what I'm aiming for. a tutorial or explanation or any other form of help/learning would be muchly appreciated!

I look forward to hearing your guys thoughts on this

Thanks in advance!

A1ien51
02-23-2007, 02:31 AM
http://developer.apple.com/internet/webcontent/xmlhttpreq.html

Eric

Arbitrator
02-23-2007, 05:50 AM
document.write() does not work in XML or XML-derived languages such as XHTML. Use DOM methods (http://www.quirksmode.org/dom/w3c_core.html) to output your code instead.

What you’re seeing in that example is the use of data drawn from an XML file into an HTML file, sort of like this (http://www.w3schools.com/dom/met_cdata_splittext.asp).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum