3

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.incompatible("xmlparse");
     }
     try{
            return Wb(textDoc);
     }
     catch(c){
            P.incompatible("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.incompatible=function(){}
;P.clear=function(){}
;

function Wb(a){
     return null;
}

2 Answers 2

1

I 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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.com/apis/maps/articles/phpsqlsearch_v3.html

Mia

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.