I want to store the data into XML file with UTF-8 encoding but it seems that it's not working..
Here is what I've so far..
public function createXML($file = 'store.xml', $products){
if(strpos($file, "xml") === FALSE){
$file .= ".xml";
}
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$r = $doc->createElement( "Products" );
$doc->appendChild( $r );
foreach( $products as $product )
{
$b = $doc->createElement( "Product" );
foreach($product as $key => $value){
if($value !== "Picture"){
$node = $doc->createElement($key);
$node->appendChild($doc->createTextNode((utf8_encode(trim($value)))));
$b->appendChild( $node );
}else{
$pictures = $doc->createElement("Picuters");
foreach($value as $pic){
$node = $doc->createElement("Picture");
$node->appendChild($doc->createTextNode((utf8_encode(trim($pic)))));
$pictures->appendChild($node);
}
$b->appendChild($pictures);
}
}
$r->appendChild( $b );
}
$doc->save($file);
}
But it is not saving data as I want it to..
data in the file is something like this..
<?xml version="1.0" encoding="utf-8"?>
<Products>
<Product>
<Brand>Milla by trendyol</Brand>
<ProductCode>Bluz</ProductCode>
<ProductName>Güpür Detaylı Bordo</ProductName>
<ProductURL>http://www.trendyol.com/Gupur-Detayli-Bordo-Bluz/UrunDetay/29920/8562520</ProductURL>
<ProductStatus>Yes</ProductStatus>
<Category>Bluz</Category>
<Gender>Kadın</Gender>
<OldPrice>69.99</OldPrice>
<Unit>TL</Unit>
<NewPrice>49.99</NewPrice>
<Picture>http://www.trendyol.com/http://s.trendyol.com/Assets/ProductImages/29043/T00400SV6A001_1_org.jpg</Picture>
<Tags>Güpür Detaylı Bordo, Güpür, Detaylı, Bordo, Butik,Kadin,Luks & Tasarim,Ayakkabi & canta,Milla by trendyol,Women</Tags>
<EndDate>29.12.2014 22:00:00</EndDate>
</Product>
</Products>
Like Gender
<Gender>Kadın</Gender>
it should be like
<Gender>Kadïn</Gender>
and other stuff likewise.
Please help....
Thanks.
UTF-8, but still the same