我完全不熟悉这一点,我正在上课,现在变成了一个令人头疼的问题。我有这个HTML DOM文件,它引用了一个XML文件,我需要在浏览器中显示在屏幕上。它应该只打印标题,标题,第一个,最后一个,位置,描述的元素。 CSS和Schema都验证了正常和工作。当我使用html文件时,我还应该将它们都保留在xml文件中吗?我在浏览器屏幕上留下空白。 感谢,利亚姆html DOM文件引用一个XML文件将不会在浏览器中打印
Catalogvar xmlDoc;
function loadXMLDoc() {
// XML loader for IE
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load("catalog.xml");
printCatalog();
}
// XML loader for other browsers
else {
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.load("catalog.xml");
xmlDoc.onload = printCatalog;
}
}
function printcatalog() {
var titleNodes = xmlDoc.getElementsByTagName("title");
var firstNodes = xmlDoc.getElementsByTagName("first");
var lastNodes = xmlDoc.getElementsByTagName("last");
var locationNodes = xmlDoc.getElementsByTagName("location");
var descriptionNodes = xmlDoc.getElementsByTagName("description");
for (var i = 0; i < titleNodes.length; i++) {
document.write("
titleNodes[i].firstChild.nodeValue + "
document.write("
firstNodes[i].firstChild.nodeValue + "
");
document.write(lastNodes[i].firstChild.nodeValue + "
");
document.write(firstNodes[i].firstChild.nodeValue + "
");
document.write(locationNodes[i].firstChild.nodeValue + "
");
document.write(descriptionNodes[i].firstChild.nodeValue + "
}
}
xs:noNamespaceSchemaLocation="catalog.xsd">
Programming 1Bill
Gates
3
100
101
Learn from the man himself, Mr. Microsoft.
Must love PCs and not Macs.
Government 1945Karl
Marx
3
200
202
Mr. Marx will explain his political theories
Lecture course. Bring lots of coffee.
Math 911Albert
Einstein
3
200
302
Find the answers to the universe in just one semester.
2010-11-09
Liam