Connecting Tech Pros Worldwide Forums | Help | Site Map

how to write special character string "Broschüren" into this format Broschüren

Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#1: Oct 13 '09
Hey all,
I am creating a xml file in this format

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  2. <customers>
  3.   <customer>
  4.     <category>Brosch&uuml;ren</category>
  5.     <number>4</number>
  6.     <email>abc@xyz.net</email>
  7.     <name>ABC XYZ</name>
  8.     <farben>4</farben>
  9.     <preflight>1</preflight>
  10.     <format>148 210</format>
  11.     <paper>135</paper>
  12.   </customer>
  13. </customers>
  14.  
But i want category tag in this format which shows special charactor.

Expand|Select|Wrap|Line Numbers
  1. <category>Broschüren</category>
  2.  
In database category values are saved in this format Brosch&uuml;ren but when i create xml then i want it shows category in this fornat Broschüren

If some one help me out to sort out my problem then i will be very grateful to him/her.

I am using DOMDocument in order to create xml file at run/execution time. and here is my method of creating xml document

Expand|Select|Wrap|Line Numbers
  1. $dom = new DOMDocument("1.0", "utf-8");
  2. $dom->xmlStandalone = true;

Awaiting a positive response from this great community

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,648
#2: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


Quote:

Originally Posted by neovantage View Post

Awaiting a positive response …

should be doable… ;)

Quote:

Originally Posted by neovantage View Post

… from this great community

ah, from me, that is. (in this forum, mostly)

ok, b2b. I’m not aware that you can convert these entities, once the xml is loaded (I’ve experienced decimal entities being converted). but you can always run htmlentities() on the input string beforehand.
Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#3: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


htmlentities() is used to convert those special chractors into string but i have already string. i need to convert string into special charactor while creating an xml.

i mean i need to convert &uuml; to ü while writing my content into xml file
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,648
#4: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


Quote:

Originally Posted by neovantage View Post

htmlentities() is used to convert those special chractors into string but i have already string.

outside XML those entities are nothing but regular characters.
Quote:

Originally Posted by neovantage View Post

i need to convert string into special charactor while creating an xml.
i mean i need to convert &uuml; to ü while writing my content into xml file

do it before creating the XML

PS. it’s character, not charactor
Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#5: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


I am doing this before creating XML. here is my code

Expand|Select|Wrap|Line Numbers
  1. $nameval=$myCategory->GetCatHierarchyByIdName(FormatString($_POST['cat_id'],"int"),'*');
  2. $nameval=htmlentities($nameval);
  3. $dom = new DOMDocument("1.0", "utf-8");
  4. $dom->xmlStandalone = true;
  5.  
function GetCatHierarchyByIdName returns category name and it saved in variable $nameval and i am aplying htmlentities() function before creating XML File

But it is not working
Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#6: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


Even this technique is also not working

Expand|Select|Wrap|Line Numbers
  1. $nameval=$myCategory->GetCatHierarchyByIdName(FormatString($_POST['cat_id'],"int"),'*');
  2.             $nameval=str_replace("&auml;","ä",$nameval);
  3.             $nameval=str_replace("&ouml;","ö",$nameval);
  4.             $nameval=str_replace("&uuml;","ü",$nameval);
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,648
#7: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


Quote:

Originally Posted by neovantage View Post

But it is not working

of course not, htmlentities()’s default charset is ISO-8859-1

PS. probably the same reason for the other way
Familiar Sight
 
Join Date: Aug 2008
Posts: 175
#8: Oct 13 '09

re: how to write special character string "Brosch&uuml;ren" into this format Broschüren


Thanks it works on remote server
Reply