0

in my code i have to show some element of an object ( a xml file), but the problem i am having is that the names of the elements contain special characters like "é", "à", "è" "ç" etc...

so when i try for example t show :

echo $xml->CoordonnéesNum->Téléphone;

it doesn't work, so i have to change it to something like this : $xml->Coor->Tel //without the special characters

but i have thousands of xml files in wich these elements are named with these special characters and i cannot change them all manually

i have to mention that im new to php:

so please if you can help to fix this issue that would be wonderful.

Steve
  • 1,553
  • 2
  • 20
  • 29
PaxBin
  • 111
  • 3
  • 14
  • You can use the complex curly syntax: `$xml->{"CoordonnéesNum"}->{"Téléphone"}` – mario Apr 01 '13 at 00:54
  • here is what i tried. $Org1 = $xml->{'CoordonnéesNum'}->{'Téléphone'}; and it didn't worked :/ – PaxBin Apr 01 '13 at 01:08
  • Is your PHP script saved in UTF-8, like the XML file? – mario Apr 01 '13 at 01:17
  • If it's saved as UTF-8 it should work like in the question. If it is not UTF-8, you can use curly brackets: `echo $xml->{"Coordonn\xC30\xA9esNum"}->{"T\xC30\xA9l\xC30\xA9phone"};` – hakre Apr 01 '13 at 01:18
  • i used the meta carset to set mypage to utf-8 and its not working, i tried also using the $xml->{"Coordonn\xC30\xA9esNum"}->{"T\xC30\xA9l\xC30\xA9phone"}; and its not working neither !! – PaxBin Apr 01 '13 at 01:30
  • it worked, my php page wasn't saved as utf-8, thank you brothers :) – PaxBin Apr 01 '13 at 01:34

1 Answers1

3

Try this instead:

echo $xml->{"CoordonnéesNum"}->{"Téléphone"};
Brad
  • 159,648
  • 54
  • 349
  • 530