Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert special characters to XML

Status
Not open for further replies.

seeyou

Programmer
Oct 11, 2002
12
PT
Hi.

I am trying to create an ExcelXP worksheet file, in a xml format.
All it seems ok, but if i use special characters, it will be replaced by another characters.

This is an example of a problematic string:
&quot;<Cell><Data ss:Type=&quot;String&quot;>Olá. É só para dizer que não sou de Guimarães</Data></Cell>&quot;

How is the best (fast) way to solve this problem?
Note: In spite of my sample has a little string, I need to replace the special chars on a quite large table, so I can't replace chars one by one (performance is very important).
--- seeyou ---
 
What happens if you open the xml file in other application, like iexplorer. Does it shows up ok?
NetAngel
 
Just remembered, are you using the WriteString method of the XmlTextWriter class?
This method auto replaces the special charecters with the right simbols:
Code:
> turns to >
< turns to <
And it gives you a good performance, as you don't have to loop the characters one by one.

Hope this helps,

NetAngel
 
Sorry, the samples I gave you were translated to html, so, it doesn't make any sence. Of corse > turns to >.
It should appear correcly now:
Code:
'>' turns to  '& g t ;'
'<' turns to  '& l t ;'
(Just take out the spaces)


PS: Just a small note to forum admin people: the code tag didn't work for this sample. NetAngel
 
Ok.

Thanks for helping me.
I solved my problem with the XmlTextWriter and the WriteRaw clause.
Now, all it´s perfect. --- seeyou ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top