I came across a google map tutorial to use XML to connect to a table on a database and print out the markers information stored in the database onto the map. I am building this in a PHP page and I keep getting a XML error XML Parsing Error: junk after document element here is the code.
Code:
<?php 
	require("Login.php");
	
	//Start XML file, create parent node
	$dom = new DOMDocument("1.0");
	$node = $dom->createElement("markers");
	$parnode = $dom->appendChild($node);
	
	//Open a connection to MySQL server
	$connection = mysql_connect(localhost, $username, $password);
		if (!$connection) 
		{
			die('Not connected : ' . mysql_error());
		}
		
	// Set the active Database
	$db_selected = mysql_select_db($database, $connection);
		if (!$db_selected)
		{
			die ('Can\'t use db : ' . mysql_error());
		}
		
	// Select all the rows in the markers table
	$query = "SELECT * FROM markers WHERE 1";
	$result = mysql_query($query);
		if (!$result)
		{
			die ('Invalid query: ' . mysql_error());
		}
		
	header("Content-type: text/xml");
	
	// Iterate through the rows, adding xml nodes for each
	while ($row = @mysql_fetch_assoc($result))
		{
			// ADD TO XML DOCUMENT NODE	
			$node = $doc->create_element("marker");
			$newnode = $parnode->append_child($node);
			
			$newnode->set_attribute("name", $row['name']);
			$newnode->set_attribute("address", $row['address']);
			$newnode->set_attribute("lat", $row['lat']);
			$newnode->set_attribute("lng", $row['lng']);
			$newnode->set_attribute("type", $row['type']);
		}
	
	$xmlfile = $doc->dump_mem();
	echo $xmlfile;
	
	?>
I hope this is the correct forum since this is both PHP and XML all help greatly appreciated. Thanks