admin管理员组文章数量:1430306
I'm trying to update my Google Maps API web application that I had running fine under version two. Version three seems not only to have broken everything but also has placed the burden of writing one's own versions of a lot of missing API functions that are no longer there.
Soooo, what was a relatively simple adaptation of their "store locator" example under version two has turned into a gigantic headache.
More specifically, my problem is parsing the XML document that my PHP/mySQL code returns after the user has entered some data into the web page and sent it off to the server. I know that the test data that I've been entering works because, 1. it worked flawlessly under V2, and 2., If I hardcode it into the PHP page and then load that page I get the expectant XML document loaded in my browser (Firefox 3.6.13 running on Snow Leopard).
Update: After very careful tracing with Firebug I've discovered that "downloadUrl" function from here is returning the data correctly.
However, it looks like the function "GXml.parse(data)" ( from here) isn't processing the returned XML. I'm pasting that code below:
function GXml(){}
GXml.value=value;
GXml.parse=parse;
function value(node){
if(!node){
return"";
}
var retStr="";
if(node.nodeType==3||node.nodeType==4||node.nodeType==2){
retStr+=node.nodeValue;
}else if(node.nodeType==1||node.nodeType==9||node.nodeType==11){
for(var i=0;i<node.childNodes.length;++i){
retStr+=arguments.callee(node.childNodes[i]);
}
}
return retStr;
}
function parse(textDoc){
try{
if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){
var b=new ActiveXObject("Microsoft.XMLDOM");
b.loadXML(textDoc);
return b;
}else if(typeof DOMParser!="undefined"){
return(new DOMParser()).parseFromString(textDoc,"text/xml");
}else{
return Wb(textDoc);
}
}
catch(c){
P.inpatible("xmlparse");
}
try{
return Wb(textDoc);
}
catch(c){
P.inpatible("xmlparse");
return document.createElement("div");
}
}
function P(){}
P.write=function(a,b){}
;P.writeRaw=function(a){}
;P.writeXML=function(a){}
;P.writeURL=function(a){}
;P.dump=function(a){}
;P.inpatible=function(){}
;P.clear=function(){}
;
function Wb(a){
return null;
}
I'm trying to update my Google Maps API web application that I had running fine under version two. Version three seems not only to have broken everything but also has placed the burden of writing one's own versions of a lot of missing API functions that are no longer there.
Soooo, what was a relatively simple adaptation of their "store locator" example under version two has turned into a gigantic headache.
More specifically, my problem is parsing the XML document that my PHP/mySQL code returns after the user has entered some data into the web page and sent it off to the server. I know that the test data that I've been entering works because, 1. it worked flawlessly under V2, and 2., If I hardcode it into the PHP page and then load that page I get the expectant XML document loaded in my browser (Firefox 3.6.13 running on Snow Leopard).
Update: After very careful tracing with Firebug I've discovered that "downloadUrl" function from here is returning the data correctly.
However, it looks like the function "GXml.parse(data)" ( from here) isn't processing the returned XML. I'm pasting that code below:
function GXml(){}
GXml.value=value;
GXml.parse=parse;
function value(node){
if(!node){
return"";
}
var retStr="";
if(node.nodeType==3||node.nodeType==4||node.nodeType==2){
retStr+=node.nodeValue;
}else if(node.nodeType==1||node.nodeType==9||node.nodeType==11){
for(var i=0;i<node.childNodes.length;++i){
retStr+=arguments.callee(node.childNodes[i]);
}
}
return retStr;
}
function parse(textDoc){
try{
if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){
var b=new ActiveXObject("Microsoft.XMLDOM");
b.loadXML(textDoc);
return b;
}else if(typeof DOMParser!="undefined"){
return(new DOMParser()).parseFromString(textDoc,"text/xml");
}else{
return Wb(textDoc);
}
}
catch(c){
P.inpatible("xmlparse");
}
try{
return Wb(textDoc);
}
catch(c){
P.inpatible("xmlparse");
return document.createElement("div");
}
}
function P(){}
P.write=function(a,b){}
;P.writeRaw=function(a){}
;P.writeXML=function(a){}
;P.writeURL=function(a){}
;P.dump=function(a){}
;P.inpatible=function(){}
;P.clear=function(){}
;
function Wb(a){
return null;
}
Share
Improve this question
edited Feb 10, 2011 at 22:53
phileas fogg
asked Feb 10, 2011 at 21:25
phileas foggphileas fogg
1,9437 gold badges29 silver badges43 bronze badges
2 Answers
Reset to default 1I dont bother parsing XML anymore.. much easier to convert it to JSON and stream it directly into objects.. one example:
Is this the fastest way to parse my XML into JavaScript objects using jQuery?
Duncan.
I'm having the same problems, but I found this after a little bit of search. I haven't followed the tutorial through all the way yet, but I thought I'd go ahead and share it.
http://code.google./apis/maps/articles/phpsqlsearch_v3.html
Mia
本文标签: javascriptGoogle Map API V3 Parsing an XML documentStack Overflow
版权声明:本文标题:javascript - Google Map API V3: Parsing an XML document - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745504437a2661180.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论