XML in Internet Exporler 4.0
since June,16 2000, last modified June 16, 2000, Working


MS Web Browser 4.0 - DATA SOURCE and DHTML

Example(musicians.xml):

<?xml version="1.0" ?> <musicians> <musician> <name>Joey Baron </name> <instrument>drums </instrument> <NrOfRecordings>1 </NrOfRecordings> </musician> <musician> <name>Bill Frisell </name> <instrument>guitar </instrument> <NrOfRecordings>3 </NrOfRecordings> </musician> <musician> <name>Don Byron </name> <instrument>clarinet </instrument> <NrOfRecordings>2 </NrOfRecordings> </musician> <musician> <name>Dave Douglas </name> <instrument>trumpet </instrument> <NrOfRecordings>1 </NrOfRecordings> </musician> </musicians>

Example(javascript.htm):

function output_doc(elem)
{
  if (elem.type == 0) //³ëµå°¡ ¿ä¼ÒÀÎÁö °Ë»ç
  {
    if (elem.tagName == "MUSICIANS") //ű׸íÀ» ´ë¹®ÀÚ·Î ¹Ýȯ
    {
      document.write("<TABLE BORDER='1' CELLPADDING='5'>"); //Å×ÀÌºí ½ÃÀÛ
      traverse(elem); //ÀÚ½Ä ³ëµå¸¦ Ⱦ´Ü
      document.write("</TABLE>");
    }              
    else if (elem.tagName == "MUSICIAN")
    {
      document.write("<TR>"); //ÁÙ ½ÃÀÛ
      traverse(elem); //ÀÚ½Ä ³ëµå¸¦ Ⱦ´Ü
      document.write("</TR>");
    }    
    else
    {
      document.write("<TD>"); //¼¿ ½ÃÀÛ
      traverse(elem); //ÀÚ½Ä ³ëµå¸¦ Ⱦ´Ü
      document.write("</TD>");
    }
            
  }
  else if (elem.type==1) //³ëµåÇüÀÌ ÅؽºÆ®ÀÎÁö °Ë»ç
    document.write(elem.text);
  else
    alert("Unknown type encountered");
}

function traverse(elem)
{
  var i;
  if (elem.children != null) // ÀÚ½Ä ¿ä¼Ò°¡ ÀÖ´ÂÁö
  {
    for (i=0; i < elem.children.length; i++) // ¸ðµç ÀÚ½ÄÀ» È®ÀÎ
      output_doc(elem.children.item(i));
  }
}   

Example(dhtm.htm):

<P>My favorite musicians are: </P>
<APPLET
code="com.ms.xml.dso.XMLDSO.class"
id="xmldso"
width="0"
height="0"
mayscript="true">
<PARAM NAME="URL" VALUE="musicians.xml">
</APPLET>
<TABLE BORDER="2" CELLPADDING="3" CELLSPACING="2" width="40%" DATASRC="#xmldso">
<THEAD>
<TH>Musician</TH>
<TH>Instrument</TH>
</THEAD>
<TR>
<TD><SPAN DATAFLD="name"></SPAN></TD>
<TD><SPAN DATAFLD="instrument"></SPAN></TD>
</TR>
</TABLE>


Knowledge & Engineering Databases (c) copyright Namchul Do, 2000