我如何使用 ':' XDocument 元素名称中的字符?
我正在使用 XDocument 创建一个 RSS,代码如下:
var document = new XDocument(
new XDeclaration("1.0", "utf-8", null),
new XElement("rss",
new XElement("channel",
new XElement("title", "test"),
new XElement("dc:creator", "test"),
执行此代码期间发生异常。
名称中不能包含“:”字符(十六进制值 0x3A)。
如何在元素名称中使用 :
字符?
I'm using XDocument to create a RSS same below code:
var document = new XDocument(
new XDeclaration("1.0", "utf-8", null),
new XElement("rss",
new XElement("channel",
new XElement("title", "test"),
new XElement("dc:creator", "test"),
An exception occurring during the execution of this code.
The ':' character, hexadecimal value 0x3A, cannot be included in a name.
How can I use :
character in a name of element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用命名空间,您需要首先创建命名空间对象:
更新
To use namespaces, you'll need to create the namespace object first:
UPDATED