首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请问"WEB1向WEB2发XML数据,得到XML数据并显示."提示"17行少""且44行缺少对象"错

2011-12-31 
请教WEB1向WEB2发XML数据,得到XML数据并显示.提示17行少且44行缺少对象.错在哪?WEB1的功能:向WEB2

请教"WEB1向WEB2发XML数据,得到XML数据并显示."提示"17行少";"且44行缺少对象".错在哪?
WEB1的功能:向WEB2发XML数据,返回XML数据并显示.
"提示 "17行少 "; ",且44行缺少对象 ".错在哪?谢谢!

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Strict//EN "     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> Sending   an   XML   Request </title>
 
<script   type= "text/javascript "   >
  var   xmlHttp;
function   createXMLHttpRequest()   {
        if   (window.ActiveXObject)   {
                xmlHttp   =   new   ActiveXObject( "Microsoft.XMLHTTP ");
        }
        else   if   (window.XMLHttpRequest)   {
                xmlHttp   =   new   XMLHttpRequest();
        }
}
 
function   createXML()   {

        var   xml= " <?xml   version= "1.0 "   encoding= "GB2312 "   standalone= "yes "?> <Msg   Version= "4 "   MsgID= "14012177 "   Type= "Down "   DateTime= "2007-04-05   10:17:13 "   SrcCode= "frew00X10 "   DstCode= "gthi00N01 "   Priority= "1 "   UserName= "Gefdwa "   PassWord= "Hofnjajdw "> <StreamSimpleQuery> <SimpleStream   Index= "0 "   EquCODE= "341200N00001 "   ChandvgyODE= "FYTV-XW "   StartDateTime= "2007-04-04   18:00:00 "   EndDateTime= "2007-04-04   18:10:00 "   Wejkh= "3d2 "   Het= "rt8 "   Fds= "25 "   Bwb= "700000 "   /> </StreamSimpleQuery> </Msg> ";
        return   xml;
}
 


function   sendPetTypes()   {
        createXMLHttpRequest();
 
        var   xml   =   createXML();
        var   url   = "http://127.144.25.202/answer ";

        xmlHttp.open( "POST ",url,false);
        xmlHttp.onreadystatechange   =   handleStateChange;
        xmlHttp.setRequestHeader( "Content-Type ",   "application/x-www-form-urlencoded ");
        xmlHttp.send(xml);
}
 
function   handleStateChange()   {
        if(xmlHttp.readyState   ==   4)   {
                if(xmlHttp.status   ==   200)   {
                        TextArea1.value=xmlHttp.responseText;
                }
        }
}
 
 
function   Button1_onclick()   {
        sendPetTypes();
}

</script>
</head>

<body>
    <h3> 发送钮: </h3>
    <input   id= "Button1 "   style= "left:   30px;   position:   relative;   top:   0px "   type= "button "   value= "button "   onClick= "Button1_onclick() ">


 
    <h3> web2回复: </h3>
    <textarea   id= "TextArea1 "   cols= "40 "   rows= "4 "   style= "position:   relative "> </textarea>
 
</body>
</html>


[解决办法]
xml字符串里的引号要转义
function createXML() {

var xml= " <?xml version=\ "1.0\ " encoding=\ "GB2312\ " standalone=\ "yes\ "?> <Msg Version=\ "4\ " MsgID=\ "14012177\ " Type=\ "Down\ " DateTime=\ "2007-04-05 10:17:13\ " SrcCode=\ "frew00X10\ " DstCode=\ "gthi00N01\ " Priority=\ "1\ " UserName=\ "Gefdwa\ " PassWord=\ "Hofnjajdw\ "> <StreamSimpleQuery> <SimpleStream Index=\ "0\ " EquCODE=\ "341200N00001\ " ChandvgyODE=\ "FYTV-XW\ " StartDateTime=\ "2007-04-04 18:00:00\ " EndDateTime=\ "2007-04-04 18:10:00\ " Wejkh=\ "3d2\ " Het=\ "rt8\ " Fds=\ "25\ " Bwb=\ "700000\ " /> </StreamSimpleQuery> </Msg> ";
return xml;
}
[解决办法]
注意一些需要转义的字符,如引号和 & 等
[解决办法]
我这里试是可以的.

热点排行