
-----------------------------------
asteffes
Mon Aug 14, 2006 1:00 pm

Suggestions for Javascript/XML flexibility?
-----------------------------------
Hello all,

A website I am working on uses javascript to read 6 headlines from an XML file and then outputs them to a  element by simply referring to the element's ID and filling it with the XML content. I need to have the ability to easily support 12 headlines.

The requirement is for a vice president here (who knows little of html/javascript/XML) simply add headlines to the XML file and have them automatically show up in the web page. 

Currently I am just stepping through the XML file and outputting which won't do the job. I need to have some type of loop and if statement, but I have limited skills with java/xml. My code below will help illustrate whats going on. Thanks so much for any help!!

Here is my html code, followed by Javascript, followed by XML:
HTML:
            
			
			
			
			...etc through "headline 6"

Javascript:

    var xmlDoc
	function loadXML()
	{
	//load xml file
	// code for IE
	if (window.ActiveXObject)
	{
	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
	xmlDoc.load("KDXHeadlines.xml");
	getmessage()
	}
	// code for Mozilla, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
	xmlDoc= document.implementation.createDocument("","",null);
	xmlDoc.load("KDXHeadlines.xml");
	xmlDoc.onload=getmessage
		}
	else	
	{
	alert('Your browser cannot handle this script');
	}
	}

function getmessage()
{
document.getElementById("headline1").innerHTML=xmlDoc.getElementsByTagName("headline1")XML 

 
  
  Our team wins 
  
  Yadda yadda 
  ...etc through 
  

To summarize, I need the ability to simply add to the xml file and have it output to the html file. I have attempted to create blank XML tags (i.e. 
 but they provoke an error.

Any help is much appreciated! I don't know where to go from here.

-----------------------------------
OneOffDriveByPoster
Wed Aug 16, 2006 12:02 am


-----------------------------------
Maybe you should try the "XHTML help" board.

You could also try looking into XSLT and server side scripting.
