XML error: The ':' character, hexadecima, value 0x3A, cannot be included in a name."

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I need to generate the following format of an XML file:
<data name="InvalidGroupType" xml:space="preserve
<value>La sélection du type de groupe nest pas valide.</value>
</data>
<data name="ProgressFailure" xml:space="preserve
<value>Liste des échecs</value>
</data>
<data name="Loronix" xml:space="preserve
<value>Loronix</value>
</data>
blah blah

So I have the following code: using(StreamWriter file = new StreamWriter(NewFile))
{
//now usage
foreach (var name in StringsToTranslatelist)
{
string result;
if (resultTranslatedLookup.TryGetValue(name, out result))
{
XElement test = new XElement("data", new XAttribute("name", name), new XAttribute("xml:space", "preserve"), new XElement("value", result));
file.WriteLine(test);
}
}
}

But I get the following error:
"An unhandled exception of type System.Xml.XmlException occurred in System.Xml.dll
Additional information: The : character, hexadecima, value 0x3A, cannot be included in a name."
How can I get around this??
The output string must be: xml:space="preserve


View the full article
 
Back
Top