Jump to content

Recommended Posts

Hello.

 

I have some issues understanding special characters and how they should be printed on screen.

For example... php takes from database an image title and it is: "Brasão" with that special "a".

In the web page it is printed correctly but inside an rss (feed file that I made) it says:

 

The XML page cannot be displayed

Reference to undefined entity 'Atilde'. Error processing resource 'http://www.jpgbox.com/feed.xml'. Line 76, Position 16

<title>Brasão Rio Grande do Sul</title>

---------------^

 

Is there a function that I can use to convert the string to be safely printed in the RSS file?

In my rss header I have application/rss+xml charset:utf-8.

I hope I explained correctly.

 

Thank you.

- Adrian.

 

Hello, the tables show latin1_swedish_ci as "collation" and the same in an upper level; I don't know if is correct or not. (These should be the default values that php my admin shown me when setting the database).

 

I later saw that I had an html_entities() done on the image_title and that was what caused the error I mentioned above in first post. I removed the html_entities() and did this:

 

$image_title = strip_tags($image_title);
$image_title = str_replace("\r\n"," ",$image_title);
$image_title = utf8_encode($image_title);

 

But when it reaches an '&' it says:

Whitespace is not allowed at this location. Error processing resource 'feed.xml'. Line 1353, Positio...
<description>Mother & daughter Golden Retriver's Molly & Elsie 

 

Do you know what I should do about this?

Should I just str_replace the '&' with something like 'and' or there is a more professional fix to avoid this?

 

Thanks.

I guess it's "manually" without XML functions ...

I have:

<?php header("content-type: application/rss+xml charset:utf-8",true);?>
<?php echo html_entity_decode('<?xml version="1.0" encoding="utf-8" ?>');?> 
...
<?php echo "<title>".$listing_title."</title>\n";?>
...

I think with XMLWriter I would have to code the whole page differently.

I tried some more things and it appears to work ok like this:

 

$listing_title = $row_Recordset_listings_rss['listing_title'];

$listing_title = strip_tags($listing_title);

$listing_title = str_replace("\r\n"," ",$listing_title);

$listing_title = htmlspecialchars($listing_title);

$listing_title = utf8_encode($listing_title);

 

Using htmlspecialchars to get rid of the errors generated by characters like "&".

So apparently it works ok now.

Thank you for your time.

 

- Adrian.

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.