Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm learning about plugins. I've built a basic Google Map plugin. But, I'm having problems putting markers on the map. I've pulled the lat long coordinates from a mySQL db. I'm following the Using PHP/MySQL with Google Maps tutorial.

My problem is that the tutorial assumes that you can call the php file in a browser to check if its producing valid XML.

I'm at the part with the heading "Using PHP's DOM functions to output XML". I'm not sure how to test whether the XML is created and being outputted correctly.

In the part about loading the XML, they use GDownloadUrl("phpsqlajax_genxml.php", function(data). But, my PHP that builds the XML is part of the main plugin file, it's not in a separate php file.

This is what I've got:

$dom = new DOMDocument('1.0');
$node = $dom->createElement('markers');
$parnode = $dom->appendChild($node);

    $csf_data = $wpdb->get_results($wpdb->prepare("SELECT  * "));             

        foreach($csf_data as $incident) {
            $node = $dom->createElement('marker');
            $newnode =  $parnode->appendChild($node);
            $newnode->setAttribute("lat", $incident->latitude);
            $newnode->setAttribute("lng", $incident->longitude);
        }

        die();

        echo $dom->saveXML;
  • a) How do I build the XML file in WordPress?
  • b) How do I load the XML file in WordPress?

Any suggestions?

Thank you.


UPDATE:

Google revised their tutorial. Please see this link.

Thank you.


UPDATE 2:

Making some progress. I figured out how to load a static XML file and place the markers on the map. Now, all I need to figure out is how to build an XML file from data pulled from the db in PHP in a WordPress plugin.

share|improve this question

closed as too localized by toscho Jul 16 '12 at 23:09

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Maybe there is a way to build the XML file following this example: wordpress.stackexchange.com/questions/6840/… If I can combine this solution with the above, it might work. –  Laxmidi Oct 5 '11 at 0:29