ssj16 Posted February 10, 2009 Share Posted February 10, 2009 Hi Guys, I've been looking all over to try and figure this out but I am new to dealing with XML in PHP. I have successfully read my XML file and echoed my data into a browser by returning a String using this function: function getTitle($filePath){ $xmlDoc = new DOMDocument(); $xmlDoc->load($filePath . "\structure.xml" ); $searchNode = $xmlDoc->getElementsByTagName( "course" ); foreach( $searchNode as $searchNode ) { $valueID = $searchNode->getAttribute('title'); return $valueID; } } But say if the value of my attribute had special characters in it such as: <structure> <course title="LOREM® IPSUM™"> </course> </structure> The output in the browser would be: LOREM® IPSUMâ„¢ If i am missing something or parsing the data wrong any help would be of assistance. Thanks Alot Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 11, 2009 Share Posted February 11, 2009 Off the top of my head, it's because by default PHP will set the character set of the page to be 8859-1. So you might try this at the top and see if that takes care of it: header('Content-type: text/html; charset=UTF-8') ; Quote Link to comment Share on other sites More sharing options...
ssj16 Posted February 11, 2009 Author Share Posted February 11, 2009 THANKS ALOT GIZMOLA I thought about this but I thought it needed to be done on the XML side, since our XML pages do not have the encoding at the top, but now that I think about it, it definitely makes more sense that it would be in the PHP page since it's being processed. Unfortunately, I never put the encoding at the top (laziness), but now I truly realize the importance of the encoding at the top of my html/php pages. Once again, thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.