munnan
12-14-2004, 04:47 PM
When I try to parse xml fixed string following code works fine. When I try to parse the string get from remote server.(bellow code example) It gives me an error unterminated string. I think this error is because of large string.How can I parse external xml file i.e http://abc.xml from the javascript ???
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(strXML)
{
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.loadXML(strXML);
xmlObj=xmlDoc.documentElement;
}
function verify()
{
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4)
{
return false;
}
}
function loadData(){//start function
var strXML=strReturnXML="";
strReturnXML="<response><request type='destination list' id='8'><language_code>ING</language_code>"+
"<agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request><country><code>ES</code><description>SPAIN</description><destination><code>IBZ</code><description>IBIZA</description><zone><code>20</code><description>SAN ANTONIO [CENTRO]</description></zone></destination><destination><code>PMI</code><description>MALLORCA</description><zone><code>20</code><description>PLAYA DE PALMA</description></zone><zone><code>31</code><description>SANTA PONSA</description></zone></destination><destination><code>MAH</code><description>MENORCA</description><zone><code>10</code><description>MAHON</description></zone></destination></country><country><code>PT</code><description>PORTUGAL</description><destination><code>FAO</code><description>ALGARVE</description><zone><code>80</code><description>ALBUFEIRA</description></zone></destination></country></response>";
loadXML(strReturnXML);
-----------------------------------------------------------------------------------------------------------
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(strXML)
{
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.loadXML(strXML);
xmlObj=xmlDoc.documentElement;
}
function verify()
{
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4)
{
return false;
}
}
function loadData(){//start function
strXML="<barceloDS_requests><request type='destination list' id='8'><language_code>ING</language_code><agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request></barceloDS_requests>";
var strUrl="http://195.57.250.36/barceloDS/interface/xml";
var objXMLHttp= new ActiveXObject("Microsoft.XMLHTTP");
//var objXMLHttp = new XMLHttpRequest();
objXMLHttp.open("POST", strUrl, true);
objXMLHttp.setRequestHeader("Content-type", "text/plain");
objXMLHttp.send(strXML);
//var strServerProcess=objXMLHttp.responseXML.strXML;
//document.write(objXMLHttp.responseText);
//alert(objXMLHttp);
objXMLHttp.onreadystatechange = function() {
if (objXMLHttp.readyState == 4 && objXMLHttp.status == 200) {
strReturnXML=objXMLHttp.responseText;
// document.write(objXMLHttp.responseText);
}
}
//objXMLHttp.send(null);
loadXML(strReturnXML);
}
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(strXML)
{
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.loadXML(strXML);
xmlObj=xmlDoc.documentElement;
}
function verify()
{
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4)
{
return false;
}
}
function loadData(){//start function
var strXML=strReturnXML="";
strReturnXML="<response><request type='destination list' id='8'><language_code>ING</language_code>"+
"<agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request><country><code>ES</code><description>SPAIN</description><destination><code>IBZ</code><description>IBIZA</description><zone><code>20</code><description>SAN ANTONIO [CENTRO]</description></zone></destination><destination><code>PMI</code><description>MALLORCA</description><zone><code>20</code><description>PLAYA DE PALMA</description></zone><zone><code>31</code><description>SANTA PONSA</description></zone></destination><destination><code>MAH</code><description>MENORCA</description><zone><code>10</code><description>MAHON</description></zone></destination></country><country><code>PT</code><description>PORTUGAL</description><destination><code>FAO</code><description>ALGARVE</description><zone><code>80</code><description>ALBUFEIRA</description></zone></destination></country></response>";
loadXML(strReturnXML);
-----------------------------------------------------------------------------------------------------------
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(strXML)
{
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.loadXML(strXML);
xmlObj=xmlDoc.documentElement;
}
function verify()
{
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4)
{
return false;
}
}
function loadData(){//start function
strXML="<barceloDS_requests><request type='destination list' id='8'><language_code>ING</language_code><agency><primary>888</primary><secondary>88</secondary><detail>888</detail><branch>1</branch></agency></request></barceloDS_requests>";
var strUrl="http://195.57.250.36/barceloDS/interface/xml";
var objXMLHttp= new ActiveXObject("Microsoft.XMLHTTP");
//var objXMLHttp = new XMLHttpRequest();
objXMLHttp.open("POST", strUrl, true);
objXMLHttp.setRequestHeader("Content-type", "text/plain");
objXMLHttp.send(strXML);
//var strServerProcess=objXMLHttp.responseXML.strXML;
//document.write(objXMLHttp.responseText);
//alert(objXMLHttp);
objXMLHttp.onreadystatechange = function() {
if (objXMLHttp.readyState == 4 && objXMLHttp.status == 200) {
strReturnXML=objXMLHttp.responseText;
// document.write(objXMLHttp.responseText);
}
}
//objXMLHttp.send(null);
loadXML(strReturnXML);
}