javascript dom /load xml netscape

admin

Administrator
Staff member
Hi guys,

Well i am having one tough time getting an xml document to laod in an html document. All i want to do is to access the data from the xml document. I have no problems setting up activexobject or data islands for ie. IE gives me no hassles. Netscape on the other hand is fighting me tooth and nail. Primarily because I probably don't know the correct method of handling it with netscape. Here is the sample code I am using from a text book for my test:


meetings.xml

<?xml version="1.0"?>
<meetings>
<meeting type="informal">
<meeting_title>xml in the real world</meeting_title>
<meeting_number>2079</meeting_number>
<subject>xml</subject>
<date>6/1/2002</date>
<people>
<person attendance="present">
<first_name>Edward</first_name>
<last_name>Samson</last_name>
</person>
<person attendance="absent">
<first_name>Ernestine</first_name>
<last_name>Johnson</last_name>
</person>
<person attendance="present">
<first_name id="betty">Betty</first_name>
<last_name>Richardson</last_name>
</person>
</people>
</meeting>
</meetings>

readxml.html:

<html>
<head>
<title>Read xml document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function Netscape()
{
var meeting,text;
meeting = xmlDoc.getElementsByTagName('meeting_title');
text = meeting.firstChild.nodeValue;
alert(text);

}

function getXml()
{
if(document.implementation && document.implementation.createDocument)
{
var xmlDoc;
xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.onload = Netscape;
xmlDoc.load('meetings.xml');
}
}
</script>
</head>

<body>

<input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"test" onClick="getXml();" />
 
Back
Top