简体   繁体   中英

The '=' character, hexadecimal value 0x3D, cannot be included in a name

 xmlnode = xmldoc.CreateElement(dRow.ItemArray.GetValue(0).ToString());
 xmlroot.AppendChild(xmlnode);     
 xmlnode.InnerText = sub;  

You can use:

string name = XmlConvert.EncodeName(dRow.ItemArray.GetValue(0).ToString());

to get a safe encoded name, then

xmlnode = xmldoc.CreateElement(name);

however; as Jon notes, this is highly unusual - and an encoded name is not pretty; for example a=b becomes a_x003D_b .

Look at the value of dRow.ItemArray.GetValue(0).ToString() . It sounds like it isn't a valid element name, due to including an = sign.

It's relatively rare to create an element with a name given dynamically from data. It's more common to specify the content of an element that way.

What exactly are you trying to achieve? What's in your row?

When you try to export a Microsoft catalog to XML, the resulting file cannot be imported, and you receive the following error message "The XML file path/filename contains an error at line. " "A Name contained an invalid character." If you validate the XML catalog by using Microsoft Visual Studio .NET you receive the following error message: "The '(' character, hexadecimal value 0x28, cannot begin a name. Line #, Position #" This problem occurs because the Commerce Server export was not encoding the following special characters:

The range 0x0021 – 0x002F includes ! “ # $ % & ‘ ( ) * + , - . /
The range 0x03A – 0x0040 includes : ; < = > ? @
The range 0x007B – 0x007E includes { | } ~
The range 0x005B – 0x005E [ \ ] ^**

The title is your answer. You can't use '=' in a name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM