非空格...运行时错误 [英] non-whitespace...runtime error

查看:87
本文介绍了非空格...运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


 

尝试

{

XDocument NameGram = new XDocument " grammar"

XDocument NameGram = new XDocument("grammar",

 

new XAttribute " mode" " voice" ),

new XAttribute("mode", "voice"),

 

new XAttribute " root" " TOPLEVEL" ),

new XAttribute("root","TOPLEVEL"),

 

new XElement " rule" new XAttribute " id" " TOPLEVEL" ),

new XElement("rule",new XAttribute("id","TOPLEVEL"),

 

new XAttribute " scope" " public" ),

new XAttribute("scope","public"),

 

new XElement " item"

new XElement("item",

 

new XComment " FIRST NAME RETURN" ),

new XComment("FIRST NAME RETURN"),

 

new XElement " item" new XAttribute " repeat" " 0-1" ),

new XElement("item", new XAttribute("repeat","0-1"),

 

new XElement " ruleref" new XAttribute " uri" " #FIRSTNAME" )),

有没有人知道这个结构有什么问题?

new XElement("ruleref",new XAttribute("uri","#FIRSTNAME")),

Does anyone know what is wrong with this construct?

推荐答案



简体:XDocument doc = new XDocument(" grammar");
您无法将文本节点添加为XDocument的子节点。 XML文档不允许根级文本节点(根据规范)。
您可能希望将其包装在根元素内。

谢谢,
Hi,

Simplified: XDocument doc = new XDocument("grammar");
You can't add a text node as a child of the XDocument. XML document doesn't allow root level text nodes (as per the spec).
You probably want to wrap it inside a root element.

Thanks,


这篇关于非空格...运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆