Skip to content

Instantly share code, notes, and snippets.

@evaisse
Created December 21, 2009 16:45
Show Gist options
  • Save evaisse/261055 to your computer and use it in GitHub Desktop.
Save evaisse/261055 to your computer and use it in GitHub Desktop.
<?php
// Start XML file, create parent node
$xml = new XMLWriter();
$xml->openMemory(); // create document in memory (AKA storing into a var)
$xml->setIndent(true); // autoindent output
$xml->setIndentString(' '); // set kind of indentation
$xml->startDocument('1.0','UTF-8'); // start xml declaration with encoding utf-8
$xml->startElement("markers");
foreach( $dbMarkers as $m )
{
$xml->startElement("marker");
$xml->writeAttribute("photo", $m['img'] );
$xml->writeAttribute("name", $m['name'] );
$xml->writeAttribute("lng", $m['lng']);
$xml->writeAttribute("lat", $m['lat']);
$xml->endElement();
}
$xml->endElement();
echo $xml->outputMemory(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment