无法调用未定义的方法'MoveFirst'加上更多问题

时间:2014-02-12 03:51:52

标签: javascript xml

我正在尝试创建的页面存在一些问题。网页的基础是您可以找到给定状态的最高记录温度。您输入州的前3个字母,并返回州名,高温,年份和城市。我正在使用XML文档。我清除了大部分错误,但仍有一些错误阻止它成为XHTML 1.0 Transitional。还有一个JavaScript控制台错误,我似乎无法找到一个好的答案。我运行了XML Schema验证器,架构和实例都是有效的。

过渡性错误:

  

“第6行,第9列:没有属性”id“
  “第6行,第23栏:没有属性”src“
  “第6行,第49栏:元素”xml“undefined

JavaScript控制台错误(第18行):

  

“无法调用未定义的方法'MoveFirst'

网页:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<xml id="dsoHiTemp" src="lab12-1temp_solution.xml"></xml>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lab 12-1 High Temperature Search</title>
<script type="text/javascript">
<!--Hide from old browsers>
function findState() {
SearchString = SearchText.value.toUpperCase()
if ((SearchString == "") || (SearchString == " ")) {
    SearchResult.innerHTML = "Sorry, There is no state like that listed. Please      check your spelling."
    return
}
        dsoHiTemp.recordset.MoveFirst()
    var outputResult=""
    while (!dsoHiTemp.recordset.EOF) {
        authorString = dsoHiTemp.recordset("Statetemps").value.toUpperCase()
        if (authorString.indexOf(SearchString)>=0)
            outputResult += dsoHiTemp.recordset("Statetemps")
            + " temperature <span style='font-style:italic; font-    weight:bold;'>" + dsoHiTemp.recordset("hiTemp")
            + dsoHiTemp.recordset("date")
            + ". City <span style='font-weight:bold; color:#cc0000;'>"
            + dsoHiTemp.recordset("city")
        dsoHiTemp.recordset.moveNext();
    }
}

function keyPressed(k) {
var hitEnter=event.keyCode
if (hitEnter==13) findState()
}

function clearField() {
SearchText.value = ""
SearchResult.innerHTML = ""
SearchText.focus()
}


//-->
</script>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium; font-weight:bold;
}
-->
</style>
</head>
<body>
<div style="margin-left:8%">
<img border="0" src="lab12-1banner.jpg" alt="banner" width="750" height="120" />
</div>
<p style="font-family:Arial, Helvetica, sans-serif; font-size:medium; font-weight:bold;   margin-left:8%">Find a state's record high temperature</p>
<p style="font-family:Arial, Helvetica, sans-serif; font-size:medium; font- weight:bold;margin-left:8%">Enter 
at least the first three letters of a state's complete name:  (e.g. Mon)<br/> 
<input type="text" id="SearchText" size="15" onkeypress="keyPressed()" />
<button onclick="findState()">Search</button>
<button onclick="clearField()">Reset</button></p>
<div style="margin-left:8%">
<img border="0" src="browndivider.jpg" alt="divider" width="750" height="5" />
</div>
<p style="font-family:Arial, Helvetica, sans-serif; font-size:large; font-weight:bold;  margin-left:8%">Results:</p>
<div id="SearchResult" style="margin-left:10%">
</div>
<div style="margin-left:8%">
<img border="0" src="browndivider.jpg" alt="divider" width="750" height="5" />
</div>

<p style="font-size: x-small; margin-left:8%">Texas Gulf Coast College Copyright  2012</p>
</body>
</html>

XSD:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:annotation>
<xs:documentation>
    This XSD describes the data structure of Weather Data Island created  February 11, 2014 by DP.
</xs:documentation>
</xs:annotation>

<xs:element name="Weather">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Statetemps" type="childType" minOccurs="1"  maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:complexType name="childType">
    <xs:group ref="childElements" />
</xs:complexType>

<xs:group name="childElements">
    <xs:sequence>
        <xs:element name="state" type="xs:string" />
        <xs:element name="hiTemp" type="xs:string" />
        <xs:element name="date" type="xs:string" />
        <xs:element name="city" type="xs:string" />
    </xs:sequence>
</xs:group>

</xs:schema>

XML相当长,但如果需要,我可以包含它。

0 个答案:

没有答案