[thelist] Is XML OT? (Long Code Sample)
Ornstein, Ian
IanOrnstein at NC.SLR.com
Thu Oct 18 15:52:15 CDT 2001
Give this a try...as I understand it you must either specify it this way or
use
this syntax:
document.getElementById("cst").innerHTML = strTxt;
case "TO":
document.YourFormName.todata.innerText=CurrentNode.text;
break;
case "FROM":
document.YourFormName.fromdata.innerText=CurrentNode.text;
break;
case "SUBJECT":
document.YourFormName.subjectdata.innerText=CurrentNode.text;
break;
case "BODY":
document.YourFormName.bodydata.innerText=CurrentNode.text;
break;
default:
document.YourFormName.todata.innerText=ErrorMessage;
document.YourFormName.fromdata.innerText=ErrorMessage;
document.YourFormName.subjectdata.innerText=ErrorMessage;
document.YourFormName.bodydata.innerText=ErrorMessage;
Ian Ornstein - Programmer and Web Developer
IBM Global Services, Global AMS Delivery
(704) 509-8022
-----Original Message-----
<snip>
Im using Win2k Pro SP2 and IE 6.
Anyone have an XML pointer they can share?
Thanks, and let me know if I owe a tip if this is OT.
--Salvatore
***CODE FOLLOWS***
<HTML>
<HEAD>
<TITLE>a</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function StartUp()
{
var RootElement1=message.documentElement;
var nodecount=RootElement1.childNodes.length;
var loopindex;
var CurrentNode;
var ErrorMessage="Error, data not defined";
if(RootElement1==null)
{
alert("The root node is null");
document.write("<B><BIG>The data of the XML file cannot be
accessed</BIG></B><BR>");
}
else
{
for(loopindex=0;loopindex<nodecount;loopindex++)
{
CurrentNode=RootElement1.childNodes.item(loopindex);
switch(CurrentNode. nodename)
{
case "TO":
todata.innerText=CurrentNode.text;
break;
case "FROM":
fromdata.innerText=CurrentNode.text;
break;
case "SUBJECT":
subjectdata.innerText=CurrentNode.text;
break;
case "BODY":
bodydata.innerText=CurrentNode.text;
break;
default:
todata.innerText=ErrorMessage;
fromdata.innerText=ErrorMessage;
subjectdata.innerText=ErrorMessage;
bodydata.innerText=ErrorMessage;
}
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="ffffff" onLoad="StartUp()" >
<XML ID=message>
<MESSAGE>
<TA>Student</TA>
<FROM>Author</FROM>
<SUBJECT>XML Code Islands</SUBJECT>
<BODY>This is an example of XML code embedded inside HTML code</BODY>
</MESSAGE>
</XML>
<DIV ID=to STYLE="font-weight:bold;color:blue">
TO:
<SPAN ID=todata></SPAN>
</DIV>
<DIV ID=from STYLE="font-weight:bold;color:teal">
FROM:
<SPAN ID=fromdata></SPAN>
</DIV>
<DIV ID=subject STYLE="font-weight:bold;color:red">
SUBJECT:
<SPAN ID=subjectdata></SPAN>
</DIV>
<DIV ID=body STYLE="font-weight:bold;color:magenta">
BODY:
<SPAN ID=bodydata></SPAN>
</DIV>
</BODY>
</HTML>
***CODE ENDS***
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.286 / Virus Database: 152 - Release Date: 10/9/2001
More information about the thelist
mailing list