求助一下大家,我编写的
<html>
<head>
<link rel="stylesheet" type="text/css" href="airport.css" />
<script type="text/javascript">function readXML(){var paraText ;
var newRow ;
var newPara ;
var newCell ;{xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("Aanda.xml");
display Airports and Airlines() ;
}
else if (document.implementation && document.implementation.createDocument)
{xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("Aanda.xml");
xmlDoc.onload=displayAirports and Airlines ;
}
else
{throw new Error("XML load is not supported by this browser") ;
} ;
function displayAirports and Airlines()
{ var units = xmlDoc.getElementsByTagName("location")
var theTable = document.getElementById("unittable")
var theTableBody = document.createElement("tbody") for(var i=0; i<units.length; i++) //for each unit element
{newRow = document.createElement("tr") //create a new table row
paraText= document.createTextNode(units[i].getElementsByTagName("airport")[0].firstChild.nodeValue)
newPara = document.createElement("p") //create an empty paragraph element
newPara.appendChild(paraText) //add text to paragraph element
newCell = document.createElement("td") //create a new table cell
newCell.appendChild(newPara) //add paragraph element to table cell
newRow.appendChild(newCell) //add cell to table row
paraText= document.createTextNode(units[i].getElementsByTagName("code")[0].firstChild.nodeValue)
newPara = document.createElement("p")
newPara.appendChild(paraText)
newCell = document.createElement("td")
newCell.appendChild(newPara)
newRow.appendChild(newCell)
theTableBody.appendChild(newRow) //add row to table body
}
theTable.appendChild(theTableBody) //add table body to table
}
</script><title>Airports and Airlines</title>
</head>
<body onload="readXML()"><h1>Airports and Airlines information</h1>
<table id="unittable" width="900px" bgcolor=#a0a0a0 border="8px"><tr><th>location</th>
<th>code</th>
<th>tel</th>
<th>adress</th>
<th>more</th>
</tr>
</table></body>
</html>
是不是有问题,用IE打开后没有我要载入的内容。
楼下我附上XML的内容和CSS的内容。谢谢大家了。
<html>
<head>
<link rel="stylesheet" type="text/css" href="airport.css" />
<script type="text/javascript">function readXML(){var paraText ;
var newRow ;
var newPara ;
var newCell ;{xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("Aanda.xml");
display Airports and Airlines() ;
}
else if (document.implementation && document.implementation.createDocument)
{xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("Aanda.xml");
xmlDoc.onload=displayAirports and Airlines ;
}
else
{throw new Error("XML load is not supported by this browser") ;
} ;
function displayAirports and Airlines()
{ var units = xmlDoc.getElementsByTagName("location")
var theTable = document.getElementById("unittable")
var theTableBody = document.createElement("tbody") for(var i=0; i<units.length; i++) //for each unit element
{newRow = document.createElement("tr") //create a new table row
paraText= document.createTextNode(units[i].getElementsByTagName("airport")[0].firstChild.nodeValue)
newPara = document.createElement("p") //create an empty paragraph element
newPara.appendChild(paraText) //add text to paragraph element
newCell = document.createElement("td") //create a new table cell
newCell.appendChild(newPara) //add paragraph element to table cell
newRow.appendChild(newCell) //add cell to table row
paraText= document.createTextNode(units[i].getElementsByTagName("code")[0].firstChild.nodeValue)
newPara = document.createElement("p")
newPara.appendChild(paraText)
newCell = document.createElement("td")
newCell.appendChild(newPara)
newRow.appendChild(newCell)
theTableBody.appendChild(newRow) //add row to table body
}
theTable.appendChild(theTableBody) //add table body to table
}
</script><title>Airports and Airlines</title>
</head>
<body onload="readXML()"><h1>Airports and Airlines information</h1>
<table id="unittable" width="900px" bgcolor=#a0a0a0 border="8px"><tr><th>location</th>
<th>code</th>
<th>tel</th>
<th>adress</th>
<th>more</th>
</tr>
</table></body>
</html>
是不是有问题,用IE打开后没有我要载入的内容。
楼下我附上XML的内容和CSS的内容。谢谢大家了。
body {background-color: d2fad2;
}#tablediv {position: absolute ;
left: 50px ;
}
table{border-collapse:collapse;
border:none;
left: 100px ;
}td, th{ border-top:solid windowtext .8pt;
border-left:solid windowtext .8pt;
border-bottom:solid windowtext .8pt;
border-right:solid windowtext .8pt;
}
td {background-color: 32a8ba ;
}th {background-color: 9ae9f5 ;
width: 70px ;
}
大致内容如下:
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<!--This data showed the information about the airports and airlines -->
<!--It was two parts-->
<!--start with airports in United Kingdom -->
<!--the airlines in United Kingdom will showed in the last element-->
<!--This element shows all the airports information--><Airports> 75 airports in Uk
<!--This is an example of a airport element.-->
<!--It starts with an attribute holding the location of airport.--><location type="South West--10 airports">
<!--The type classify by the location-->
<airport>Bristol Airport<!--This element showed the name of the airport -->
<code>BRS</code><!--This element showed the code of the airport -->
<telephone>+44(0)870 121 2747</telephone><!--This element showed the telephone of the ariport -->
<address>Bristol International Airport,Bristol,BS48 3DY</address><!--This element showed the adress of the ariport -->
<more>Bristol International Airport is located 8 miles south of the city centre. The airport began in 1929 </more><!--This element showed more information of the airport-->
</airport><airport>Cardiff Airport
<code>CWL</code>
<telephone>+44(0)144 671 1111</telephone>
<address> Cardiff International Airport,Vale of Glamorgan,CF62 3BD,Wales </address>
<more>Cardiff Airport is located in Rhoose, 12 miles west of Cardiff City centre.</more>
</airport><airport>Exeter Airport
<code>EXT</code>
<telephone>+44(0)139 236 7433</telephone>
<address>Exeter Airport,Exeter,Devon,EX5 2BD</address>
<more>Exeter airport is situated 5 miles east of the city centre. It was originally opened on 31st May 1937.</more>
</airport><airport>Gloucestershire Airport
<code>GLO</code>
<telephone>+44 (0)145 285 7700</telephone>
<address>Gloucestershire Airport,Staverton,Cheltenham,Gloucester,GL51 6SR </address>
<more>Gloucestershire airport lies mid way between Gloucester and Cheltenham at Staverton.</more>
</airport><airport>Lands End Airport
<code>null</code>
<telephone>+44 (0)173 678 8771</telephone>
<address>Lands End Airport,Kelynack,St. Just,PENZANCE,Cornwall,TR19 7RL </address>
<more>Lands End Airport is located close to Penzance and there are good transport links from here.</more>
</airport><airport>Newquay Airport
<code>NQY</code>
<telephone>null</telephone>
<address>Newquay Cornwall Airport,St Mawgan,Cornwall,TR8 4HP</address>
<more>Newquay Airport is located about 5 miles northeast of Newquay town centre from which there are good road. </more>
</airport><airport>Penzance Airport
<code>PZE</code>
<telephone>+44 (0)173 636 4296</telephone>
<address>Penzance Heliport,Penzance,Cornwall,TR18 3AP </address>
<more>Penzance Heliport is located close to the centre of Penzance and sees over 100,000 passengers through its terminal each year. </more>
</airport>等等。
<html>
<head>
<link rel="stylesheet" type="text/css" href="airport.css" />
<script type="text/javascript"> function readXML() {
var paraText;
var newRow;
var newPara;
var newCell;
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("Aanda.xml");
displayAirportsAirlines();
}
else if (document.implementation && document.implementation.createDocument) {
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.load("Aanda.xml");
xmlDoc.onload = displayAirportsAirlines;
}
else {
throw new Error("XML load is not supported by this browser");
}
};
function displayAirportsAirlines() { var units = xmlDoc.getElementsByTagName("location")
var theTable = document.getElementById("unittable")
var theTableBody = document.createElement("tbody") for (var i = 0; i < units.length; i++) //for each unit element
{
newRow = document.createElement("tr") //create a new table row
paraText = document.createTextNode(units[i].getElementsByTagName("airport")[0].firstChild.nodeValue)
newPara = document.createElement("p") //create an empty paragraph element
newPara.appendChild(paraText) //add text to paragraph element
newCell = document.createElement("td") //create a new table cell
newCell.appendChild(newPara) //add paragraph element to table cell
newRow.appendChild(newCell) //add cell to table row
paraText = document.createTextNode(units[i].getElementsByTagName("code")[0].firstChild.nodeValue)
newPara = document.createElement("p")
newPara.appendChild(paraText)
newCell = document.createElement("td")
newCell.appendChild(newPara)
newRow.appendChild(newCell)
theTableBody.appendChild(newRow) //add row to table body
}
theTable.appendChild(theTableBody) //add table body to table
}
</script>
<title>Airports and Airlines</title>
</head>
<body onload="readXML()">
<h1>
Airports and Airlines information</h1>
<table id="unittable" width="900px" bgcolor="#a0a0a0" border="8px">
<tr>
<th>
location
</th>
<th>
code
</th>
<th>
tel
</th>
<th>
adress
</th>
<th>
more
</th>
</tr>
</table>
</body>
</html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="airport.css" />
<script type="text/javascript"> function readXML() {
var paraText;
var newRow;
var newPara;
var newCell;
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("Aanda.xml");
displayAirportsAirlines();
}
else if (document.implementation && document.implementation.createDocument) {
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.load("Aanda.xml");
xmlDoc.onload = displayAirportsAirlines;
}
else {
throw new Error("XML load is not supported by this browser");
}
};
function displayAirportsAirlines() { var units = xmlDoc.getElementsByTagName("location")
var theTable = document.getElementById("unittable")
var theTableBody = document.createElement("tbody") for (var i = 0; i < units.length; i++) //for each unit element
{
newRow = document.createElement("tr") //create a new table row
paraText = document.createTextNode(units[i].getElementsByTagName("airport")[0].firstChild.nodeValue)
newPara = document.createElement("p") //create an empty paragraph element
newPara.appendChild(paraText) //add text to paragraph element
newCell = document.createElement("td") //create a new table cell
newCell.appendChild(newPara) //add paragraph element to table cell
newRow.appendChild(newCell) //add cell to table row
paraText = document.createTextNode(units[i].getElementsByTagName("code")[0].firstChild.nodeValue)
newPara = document.createElement("p")
newPara.appendChild(paraText)
newCell = document.createElement("td")
newCell.appendChild(newPara)
newRow.appendChild(newCell)
theTableBody.appendChild(newRow) //add row to table body
}
theTable.appendChild(theTableBody) //add table body to table
}
</script>
<title>Airports and Airlines</title>
</head>
<body onload="readXML()">
<h1>
Airports and Airlines information</h1>
<table id="unittable" width="900px" bgcolor="#a0a0a0" border="8px">
<tr>
<th>
location
</th>
<th>
code
</th>
<th>
tel
</th>
<th>
adress
</th>
<th>
more
</th>
</tr>
</table>
</body>
</html>