transformer un tableau associatif en php vers xml
salut
j'ai un tableau associatif en php qui contient plusieurs des sous tableaux, ces tableaux contiennent des caractères spéciaux,je veux les transformer en xml et particulièrement à simplexml,mais je pense que j'ai un problème avec tout ce qui est accent, caractère speciaux, pourrez vous m'aider svp ??.
Mon code PHP:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <?php
$xml_page_info = new SimpleXMLElement( '<pageinfo/>' );
// function defination to convert array to xml
function array_to_xml($student_info, $xml_page_info) {
foreach($student_info as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $xml_page_info->addChild("$key");
array_to_xml($value, $subnode);
}
else{
array_to_xml($value, $xml_page_info);
}
}
else {
$xml_page_info->addChild($key,$value);
}
}
return $xml_page_info;
}
// function call to convert array to xml
echo array_to_xml($wall,$xml_page_info)->asXML();
exit( ) ;
?> |
Et voici la réponse:
Code:
1 2 3 4 5 6 7 8
| Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference set=a.153490351389141.38937.153383058066537&type=1 in C:\Program Files (x86)\EasyPHP-5.3.9\www\fbcnx.php on line 19
Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference s_app=326914550570&s_uid=1509985731&said=1022&spid=1457&src=101&t_link=app&t_ratio=1&t_story=FriendInterviewStory in C:\Program Files (x86)\EasyPHP-5.3.9\www\fbcnx.php on line 19
Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference since=1356700238&limit=25&__previous=1 in C:\Program Files (x86)\EasyPHP-5.3.9\www\fbcnx.php on line 19
Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference limit=25&until=1356128619 in C:\Program Files (x86)\EasyPHP-5.3.9\www\fbcnx.php on line 19
1509985731_102002428992643882012-12-28T13:10:38+00001509985731_314820988634241Timeline Photoshttp://www.facebook.com/photo.php?fbid=4350816965633372012-12-26T17:29:39+00001509985731_10200228490104168Friend Interviewhttp://apps.facebook.com/friendinterview/y/?ctx=sa2012-12-26T02:44:15+00001509985731_102002275596809082012-12-25T23:45:31+00001509985731_102002275541207692012-12-25T23:44:49+00001509985731_102002126684686372012-12-23T17:28:24+00001509985731_102002102959693262012-12-23T09:42:17+00001509985731_315477878551691Le plus grand programmeur de tout les temps !<a href="http://www.facebook.com/photo.php?v=102001709127762362012-12-21T22:23:40+0000https://graph.facebook.com/1509985731/feed?fields=id,name,likes,comments.fields%28message,created_time,like_count,user_likes%29,message,linkhttps://graph.facebook.com/1509985731/feed?fields=id,name,likes,comments.fields%28message,created_time,like_count,user_likes%29,message,link" target="_blank">http://www.facebook.com/photo.php?v=...9,message,link</a> |