Jump to content

XML Parsing Error: not well-formed using php


dflow

Recommended Posts

erro:

XML Parsing Error: not well-formed

<Description><![CDATA[The economy and basic

structured in the table:

Description  longtext utf8_bin

 

im using this code:

 

<?php

mysql_select_db($database_international, $international);
$query_rsAll = "SELECT * FROM apartments";
$rsAll = mysql_query($query_rsAll, $international) or die(mysql_error());
$row_rsAll = mysql_fetch_assoc($rsAll);
$totalRows_rsAll = mysql_num_rows($rsAll);

// Send the headers
header('Content-type: text/xml');
header('Pragma: public');        
header('Cache-control: private');
header('Expires: -1');
?><?php echo('<?xml version="1.0" encoding="utf-8"?>'); ?>
<root>
  <?php if ($totalRows_rsAll > 0) { // Show if recordset not empty ?>
  <?php do { ?>
<row>
	<?php foreach ($row_rsAll as $column=>$value) { ?>
	<<?php echo $column; ?>><![CDATA[<?php echo $row_rsAll[$column]; ?>]]></<?php echo $column; ?>>
	<?php } ?>
</row>
    <?php } while ($row_rsAll = mysql_fetch_assoc($rsAll)); ?>
<?php } // Show if recordset not empty ?>
</root>
<?php
mysql_free_result($rsAll);
?>

The error might be about the uppercase 'D'. Otherwise it'd help to know what the XML is.

 

Blanket solution: it's easier to use htmlspecialchars instead of a CDATA block.

", htmlspecialchars($value), "$column>"; ?>

The error might be about the uppercase 'D'. Otherwise it'd help to know what the XML is.

 

Blanket solution: it's easier to use htmlspecialchars instead of a CDATA block.

<?php $column = strtolower($column); echo "<$column>", htmlspecialchars($value), "</$column>"; ?>

 

ok

 

how would i create from the above code an internal node for the image gallery?

i have  the gallery in the images table :id, imageURL

LEFT JOIN images on apartments.ID = images.id WHERE apartments.id=35200  ?

<apartment>
<images>
<image>
</image>
<images>
</apartment>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.