繁体   English   中英

XSL Javascript验证错误

[英]Error with XSL validation of Javascript

我在将代码放入正在使用的第3方应用程序之前尝试验证代码时,遇到诸如“没有处理指令以'xml ....开头”的验证错误。 如何使用嵌入在XSL页面上的Javasript发送一条肥皂消息,而不会出现此错误? 这是有问题的代码:

<script language="javascript">

 function test1(newSymbol){

 var symbol = newSymbol;  
 var xmlhttp = new XMLHttpRequest(); 

 xmlhttp.open("POST", "http://www.webservicex.net/stockquote.asmx?op=GetQuote",true); 
 xmlhttp.onreadystatechange=function() { 
  if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { 
     alert(xmlhttp.responseText); 
   // http://www.terracoder.com convert XML to JSON  
   var json = XMLObjectifier.xmlToJSON(xmlhttp.responseXML); 
   var result = json.Body[0].GetQuoteResponse[0].GetQuoteResult[0].Text; 
   // Result text is escaped XML string, convert string to XML object then convert      to      JSON object 
   json = XMLObjectifier.xmlToJSON(XMLObjectifier.textToXML(result)); 
   alert(symbol + ' Stock Quote: $' + json.Stock[0].Last[0].Text + '\n' + 'Company      Name: ' + json.Stock[0].Name[0].Text);  
   document.getElementById('price').innerHTML = json.Stock[0].Last[0].Text;
   document.getElementById('name').innerHTML = json.Stock[0].Name[0].Text;

   }
   else if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status != 200) {
   alert('Server Issue');

   } 
 } 
 xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote"); 
 xmlhttp.setRequestHeader("Content-Type", "text/xml"); 
 var xml = '<?xml version="1.0" encoding="utf-8"?>' + 
  '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' + 
                 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' + 
                 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +  
    '<soap:Body> ' + 
      '<GetQuote xmlns="http://www.webserviceX.NET/"> ' + 
        '<symbol>' + symbol + '</symbol> ' + 
      '</GetQuote> ' + 
    '</soap:Body> ' + 
  '</soap:Envelope>'; 
 xmlhttp.send(xml); 
 }

 </script>

我在声明soap标头后立即在var xml =行上收到错误。

感谢您的帮助! :)

只需删除XML声明:在这种情况下就没有必要,因为版本和编码伪属性指定了默认值-1.0和utf-8。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM