简体   繁体   中英

XmlWriter The ':' character, hexadecimal value 0x3A, cannot be included in a name

I am using an XmlWriter and getting the following error:

Invalid name character in 'news:news'. The ':' character, hexadecimal value 0x3A, cannot be included in a name.

You need to use the overload of WriteStartElement that takes two parameters:

writer.WriteStartElement("news", "http://www.google.com/schemas/sitemap-news/0.9");
//               Tag   ----^       ^--- Namespace

I used this code:

writer.WriteStartElement("wp","wxr_version", null);

To get this result:

<wp:wxr_version>

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