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 9128083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:25:47+00:00 2026-06-17T07:25:47+00:00

In addition to my previous question about parsing images and text from complex xml

  • 0

In addition to my previous question about parsing images and text from complex xml, only problem about that now is that i don’t get the right encoding. Text is in greek, the xml file has utf-8 encoding.
This is the code to parse xml:

$xml = simplexml_load_file('myfile.xml');

$descriptions = $xml->xpath('//item/description');

foreach ( $descriptions as $description_node ) {

    $description_dom = new DOMDocument();
    $description_dom->loadHTML( (string)$description_node );

    $description_sxml = simplexml_import_dom( $description_dom );

    $imgs = $description_sxml->xpath('//img');
    $text = $description_sxml->xpath('//div');

    foreach($imgs as $image){

    echo (string)$image['src'];     
       }

    foreach($text as $t){
    
        echo (string)$t;
       }
    }

If i echo $description_node,text looks fine, but after i get $description_dom with simplexml_import_domit looks like this:
Ïε ιÏÎ»Î±Î¼Î¹ÎºÎ­Ï ÎºÎ¿Î¹Î½ÏÏηÏεÏ.Using mb_convert_encoding turns it to:
ýÃÂñù" ÃÂ. What am i doing wrong?

  • 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-06-17T07:25:48+00:00Added an answer on June 17, 2026 at 7:25 am

    Solution: after $description_dom = new DOMDocument(); , i placed this code.

    $description_html = mb_convert_encoding($description_node, 'HTML-ENTITIES', "UTF-8");
    

    Simply converts html entities to UTF-8. Instead of

    $description_dom->loadHTML( (string)$description_node );
    

    now i load the converted html

    $description_dom->loadHTML( (string)$description_html );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In addition to my previous question , another problem appeared and I decided to
It's an addition for previous my question about adding columns into jqGrid-based table. Here
In my previous question , Andrew Jaffe writes : In addition to all of
Previous question which links onto this and has any addition code ref should I
This is a follow up to my previous question (about an old top coder
Continuing from the previous question I'd like to ask why the friend form of
Is addition(+) operation more complex than comparison operation (>), both in integer as well
In addition to this question: iPhone network performance , I would like to know
Objective Initialize a new addition problem for users to solve when they visit /task
I have started the previous question, but I want to change the method of

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.