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);
?>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.