Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6669847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:11:57+00:00 2026-05-26T03:11:57+00:00

I generate a lot of posts in WordPress from an XML file. The worry:

  • 0

I generate a lot of posts in WordPress from an XML file. The worry: accented characters.

The header of the stream is:

<? Xml version = "1.0" encoding = "ISO-8859-15"?>

Here is the complete flux : http://flux.netaffiliation.com/rsscp.php?maff=177053821BA2E13E910D54

My site is in utf8.

So I use the function utf8_encode … but that does not solve the problem, the accents are always misunderstood.

Does anyone have an idea?

EDIT 04-10-2011 18:02 (french hour) :

Here is the complete flux : http://flux.netaffiliation.com/rsscp.php?maff=177053821BA2E13E910D54

Here is my code :

/**
 * parse an rss flux from netaffiliation and convert each item to posts
 * @var $flux = external link
 * @return bool
 */
private function parseFluxNetAffiliation($flux)
{
    $content = file_get_contents($flux);
    $content = iconv("iso-8859-15", "utf-8", $content);

    $xml = new DOMDocument;
    $xml->loadXML($content);

    //get the first link : http://www.netaffiliation.com
    $link = $xml->getElementsByTagName('link')->item(0);
    //echo $link->textContent;

    //we get all items and create a multidimentionnal array
    $items = $xml->getElementsByTagName('item');

    $offers = array();
    //we walk items
    foreach($items as $item)
    {
        $childs = $item->childNodes;

        //we walk childs
        foreach($childs as $child)
        {
            $offers[$child->nodeName][] = $child->nodeValue;
        }

    }
    unset($offers['#text']);

    //we create one article foreach offer
    $nbrPosts = count($offers['title']);

    if($nbrPosts <= 0) 
    {
        echo self::getFeedback("Le flux ne continent aucune offre",'error');
        return false;
    }

    $i = 0;
    while($i < $nbrPosts)
    {
        // Create post object
        $description = '<p>'.$offers['description'][$i].'</p><p><a href="'.$offers['link'][$i].'" target="_blank">'.$offers['link'][$i].'</a></p>';

        $my_post = array(
            'post_title' => $offers['title'][$i],
            'post_content' => $description,
            'post_status' => 'publish',
            'post_author' => 1,
            'post_category' => array(self::getCatAffiliation())
        );

        // Insert the post into the database
        if(!wp_insert_post($my_post));;

        $i++;
    }

    echo self::getFeedback("Le flux a généré {$nbrPosts} article(s) depuis le flux NetAffiliation dans la catégorie affiliation",'updated');
    return false;

}

All the posts are generated but… the accented chars are ugly. You can see the result here: http://monsieur-mode.com/test/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:11:57+00:00Added an answer on May 26, 2026 at 3:11 am

    mb_convert_encoding()saves my life.

    Here is my solution :

        $content = preg_replace('/ encoding="ISO-8859-15"/is','',$content);
        $content = mb_convert_encoding($content,"UTF-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a lot of mysql data that I need to generate reports from.
I've seen there are a lot of posts about XML comparison, but none of
I need to generate an RSS feed for posts in WordPress that contains more
Ruby on Rails has a lot of ways to generate JavaScript. Particularly when it
I've read a lot of the posts here giving profiling advice but I need
So I've read a lot of related posts on SO and elsewhere such as:
After a lot of posts in SO and Google, I could not find an
There is a lot of posts about nested Ajax problems, but I can't figure
Hey, There's a lot of posts on here about read barcodes but I want
I want to send a csv file from Android to Python AppEngine. I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.