TObannion 0 Junior Poster in Training

I am trying to create a dtd that emulates a car dealership. It sells trucks, sedans and hatchbacks, as can be seen in my dtd.
The dealership would keep track of how many doors and wheels each vehicle has as well as the model and year in addition to how many of each vehicle is currently on the lot.
Then I have an XML document that has three models of those vehicle types. THEN, I have an HTML file that is supposed to use Ajax to display a list of those models at the dealership lot.
Yes I am confused as to how this is done. Here are my three files:

Dealership.dtd

    <!ELEMENT vehicletype (trucks,sedans,hatchbacks)>
    <!ELEMENT trucks (#PCDATA)>
      <!ELEMENT model(#PCDATA)>
        <!ELEMENT year(#PCDATA)>
          <!ELEMENT numdoors(#PCDATA)>
          <!ELEMENT numwheels(#PCDATA)>
            <!ELEMENT numinstock(#PCDATA)
    <!ELEMENT sedans(#PCDATA)>
      <!ELEMENT model(#PCDATA)>
        <!ELEMENT year(#PCDATA)>
          <!ELEMENT numdoors(#PCDATA)>
          <!ELEMENT numwheels(#PCDATA)>
            <!ELEMENT numinstock(#PCDATA)
    <!ELEMENT hatchbacks(#PCDATA>
      <!ELEMENT model(#PCDATA)>
        <!ELEMENT year(#PCDATA)>
          <!ELEMENT numdoors(#PCDATA)>
          <!ELEMENT numwheels(#PCDATA)>
            <!ELEMENT numinstock(#PCDATA)

CarModel.xml

<?xml version= "1.0" encoding = "UTF-8"?>
<!doctype vehicletype SYSTEM "Dealership.dtd">
  <vehicletype>
    <truck>
      <model>F150,Explorer,Navigator</model>
        <year>2000,2001,2002</year>
          <numdoors>2,3,4</numdoors>
          <numwheels>4,6</numwheels>
    </truck>
    <sedan>
      <model>Civic,Sonata,Beetle</model>
        <year>2000,2001,2002</year>
          <numdoors>2,3,4</numdoors>
          <numwheels>4,6</numwheels>
    </sedan>
    <hatchback>
      <model>Veloster,Gremlin,CRX</model>
        <year>2000,2001,2002</year>
          <numdoors>2,3,4</numdoors>
          <numwheels>4,6</numwheels>
    </hatchback>
  </vehicletype>

...and finally, the html:

<!doctype html>
<html>
  <meta charset = "utf-8">
  <head>
    <script type = "text/javascript">
      function loadDoc()
        {
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function()
            {
              if(xhttp.readyState == 4 && xhttp.status == 200)
                {
                  inventory(xhttp);
                }
            };
            xhttp.open("GET", "CarModel.xml", true);
            xhttp.send();
        }
      function inventory()
        {
          var i;
          var xmlDoc = .responseXML;
          var trucks = "<tr><th>truck</th><th>model</th></tr>";
          var sedans = "<tr><th>sedan</th><th>model</th></tr>";
          var hatchbacks = "<tr><th>hatchback</th><th>model</th></tr>";
          var x = smlDoc.getElementsByTagName("vehicle");
            for(i = 0; i<x.length; i++)
              {
                trucks += "<tr><td>"+
                  x[i].getElementsByTagName("Model")[0].childNodes[0].nodeValue +
                    "</td></tr>";
              }
                document.getElementById("demo").innerHTML = trucks;
            for(i = 0; i<x.length; i++)
              {
                sedans += "<tr><td>"+
                  x[i].getElementsByTagName("model")[0].childNodes[0].nodeValue +
                    "</td></tr>";
              }
                document.getElementById("demo").innerHTML = sedans;
            for(i = 0; i<x.length; i++)
              {
                hatchbacks += "<tr><td>"+
                  x[i].getElementsByTagName("model")[0].childNodes[0].nodeValue +
                    "</td></tr>";
              }
                document.getElementById("demo").innerHTML = hatchbacks;
        }
    </script>
  </head>
  <body onload = "inventory()">
  </body>
</html>

I am sure my biggest mistake(s) are inside the html. Can someone show me what I'm doing wrong? I've tried my text and regular internet searches, with no real answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.