# XML and illegal characters



## CarpeDiem (Dec 3, 2004)

I am developing an application that reads/writes an XML file using C# and .NET 2003. The XML file contains nodes that have names with colons. An example of a node would be:

<X:Y>

I have been unable to find a way to use a colon in the node name. When the XML file is serialized, the node names are changes to

<X_0x003A_Y>

And no matter what I do, it doesn't seem to fix the problem. I have seen similar posts on other forums but no answers. Any suggestions on what I can do to get around this issue?


----------



## brendandonhu (Jul 8, 2002)

I'm not sure if there is a workaround for that, but using a colon in your XML element names is highly discouraged...the colon has special meaning in XML and can cause confusion in regards to namespaces.


----------



## CarpeDiem (Dec 3, 2004)

The reason for the colon is I have a small MP3 tag and RSS creation application and I need to incorporate iTunes tags. Unfortunately, Apple requires the tags be <X:Y> format and nothing else. So I need to be able to incorporate the colon in the node name.


----------



## CarpeDiem (Dec 3, 2004)

I believe I found the answer. In looking through this document:

http://www.vijaymukhi.com/documents/books/xsd/chap8.htm

I discovered I have to use XmlSerializerNamespaces and pass that into the Serializer. It associates the namespace prefix with the tag and uses the colon as a separator.


----------

