473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

writing the " © " character in xml file using c#.net xmltextwriter

Hi,

I have a doubt related to xml. I want to print the copyright “©” symbol … but I wan to do it programmatically and without using the symbol directly. Hence I am using the ASCII value (© ) for that instead of the actual character.

Sample code for it is as follows.

XmlTextWriter xtw = new XmlTextWriter("test.xml", Encoding.UTF8);
xtw.WriteStartElement("root");
xtw.WriteString("(©) " + DateTime.Now.Year.ToString() +All rights reserved.");
xtw.WriteFullEndElement();
xtw.Close();

however it gives the below output.

<root>&amp;#169; 2007 All rights reserved.</root>


But I want the output to come as follows.

<root> © 2007 All rights reserved.</root>


Let me know where I am going wrong.

-Anil
Jun 19 '07 #1
1 2820
Dököll
2,364 Expert 2GB
Hi,

I have a doubt related to xml. I want to print the copyright “©” symbol … but I wan to do it programmatically and without using the symbol directly. Hence I am using the ASCII value (© ) for that instead of the actual character.

Sample code for it is as follows.
Expand|Select|Wrap|Line Numbers
  1. XmlTextWriter xtw = new XmlTextWriter("test.xml", Encoding.UTF8);
  2.             xtw.WriteStartElement("root");
  3.             xtw.WriteString("(©)  " + DateTime.Now.Year.ToString() +All rights reserved.");
  4.             xtw.WriteFullEndElement();
  5.             xtw.Close();
  6.  
however it gives the below output.

<root>&amp;#169; 2007 All rights reserved.</root>


But I want the output to come as follows.

<root> © 2007 All rights reserved.</root>


Let me know where I am going wrong.

-Anil
Have you tried removing the parenthesis?

I'll give it a go when I have a minute!
Jun 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Pete | last post by:
I have not encountering this problem 'till I got VS.NET 2003. Check my xml below how the backlash is added. I tried all possible ways to replace it but nothing happens. Any help will greatly...
2
by: Amil Hanish | last post by:
I am trying to use XmlTextWriter. I write the xml data fine, but the file is missing the first line that shows the version and encoding: <?xml version="1.0" encoding="utf-8"?> Can the...
3
by: Amy L. | last post by:
I am using the xml serializer to serialize the objects out of a collection into a file. The object that is being serialized is a class in my application. When I serialize my class it produces the...
3
by: Dan | last post by:
Is there a better way to include the XML declaration than the following? XmlDeclaration dec =m_XMLDocument.CreateXmlDeclaration("1.0",string.Empty, "yes");...
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
1
by: Dan | last post by:
How would I write an XmlDocument to a file so that each node is properly indented and followed by a carriage return? Thanks...Dan
7
by: GS | last post by:
Hi! I am getting an "Invalid Xml" exception when I try to load an xsl file using XslTransform.Load(string url). The Xsl file is valid and works fine if I just rename the file. There are some...
4
by: Paul Hadfield | last post by:
Hi, Wonder if anyone can help me on this, In DotNet2.0 I've been quite happily using the WriteAttributeString method of XmlWriter object, but have run into a problem when trying to output a...
3
by: lisa.bogart | last post by:
I am getting a "Root element is missing" error when I try to load a stream into and XmlDocument. Can anyone help me with what I am doing wrong??? Dim xmlTextWriter As XmlTextWriter = Nothing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.