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?