Technology

Creating Website Content with Excel

        So I was designing a site using HTML, not ASP.NET or PHP, or some other language that would have made this easier, but I was using just plain old HTML. And I needed to have a table that they could easily update, so XML data source it is. I had a lot of trouble getting it to work, but finally I did. Here is the code with place-marks:

<script type=”text/javascript”>
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest    ();}
   
else {// code for IE6, IE5 xmlhttp = new ActiveXObject (“Microsoft.XMLHTTP”);}
    xmlhttp.open(“GET”, “*XMLFILENAME*”, false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    document.write(“<table border=’1′ bordercolor=’#000000′>”);
    var x = xmlDoc.getElementsByTagName(“*GROUPNAME*”);
    for (i = 0; i < x.length; i++)
    {
        document.write(“<tr><td>”);
        document.write(x[i].getElementsByTagName(“*COLUMN1*”)[0].childNodes[0].nodeValue);
        document.write(“</td><td>”);
        document.write(x[i].getElementsByTagName(“*COLUMN2*”)[0].childNodes[0].nodeValue);
        document.write(“</td><td>”);
        document.write(x[i].getElementsByTagName(“*COLUMN3*”)[0].childNodes[0].nodeValue);
        document.write(“</td></tr>”);
    }
    document.write(“</table>”);
</script>
And here are the contents of the XML file:
xml version=”1.0″ encoding=”ISO-8859-1″?>
<CATALOG>
    <GROUP>
        <COLUMN1>COLUMN TITLE</COLUMN1>
        <COLUMN2>COLUMN TITLE</COLUMN2>
        <COLUMN3>COLUMN TITLE</COLUMN3>
    </GROUP>
    <GROUP>
        <COLUMN1>VALUE1</COLUMN1>
        <COLUMN2>VALUE1</COLUMN2>
        <COLUMN3>VALUE1</COLUMN3>
    </GROUP>
    <GROUP>
        <COLUMN1>VALUE2</COLUMN1>
        <COLUMN2>VALUE2</COLUMN2>
        <COLUMN3>VALUE2</COLUMN3>
    </GROUP>
</CATALOG>

        Now, the client can open the XML file in Excel and edit the values, change the order, etc and transfer the file to the server and the table will update.

One thought on “Creating Website Content with Excel

  • Looks like Greek to me :))
    Bryan

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *