Tema: Dom xml
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/02/2014, 09:37
mktalternativa
 
Fecha de Ingreso: enero-2012
Mensajes: 224
Antigüedad: 12 años, 3 meses
Puntos: 1
Dom xml

hola estoy parseando unos datos y me da este error que puedo estar haciendo mal
gracias

This page contains the following errors:

error on line 4 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.


Código PHP:
<?php require_once('dbconect.php'); ?>
<?php
$dom 
= new DOMDocument("1.0");
$node $dom->createElement("markers");
$parnode $dom->appendChild($node); 

// Opens a connection to a MySQL server

$connection=mysql_connect ('localhost'$username$password);
if (!
$connection) {  die('Not connected : ' mysql_error());} 

// Set the active MySQL 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 reclamos ";
$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 $dom->createElement("marker");  
  
$newnode $parnode->appendChild($node);   

 
$newnode->setAttribute("name"$row['nombre']);
  
$newnode->setAttribute("address"$row['direccion']);
  
$newnode->setAttribute("lat"$row['latitud']);
  
$newnode->setAttribute("lng"$row['longitud']);
  
$newnode->setAttribute("type"$row['area']);


echo 
$dom->saveXML();
?>

<html>

        
  <head>
  
  </head>
  <body>
    
  </body>
</html><?php require_once('dbconect.php'); ?>
<?php
$dom 
= new DOMDocument("1.0");
$node $dom->createElement("markers");
$parnode $dom->appendChild($node); 

// Opens a connection to a MySQL server

$connection=mysql_connect ('localhost'$username$password);
if (!
$connection) {  die('Not connected : ' mysql_error());} 

// Set the active MySQL 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 reclamos ";
$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 $dom->createElement("marker");  
  
$newnode $parnode->appendChild($node);   

 
$newnode->setAttribute("name"$row['nombre']);
  
$newnode->setAttribute("address"$row['direccion']);
  
$newnode->setAttribute("lat"$row['latitud']);
  
$newnode->setAttribute("lng"$row['longitud']);
  
$newnode->setAttribute("type"$row['area']);


echo 
$dom->saveXML();
?>

<html>

        
  <head>
  
  </head>
  <body>
    
  </body>
</html>