Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用LINQ to Xml时发生System.Xml.XmlException错误_C#_Xml_Linq - Fatal编程技术网

C# 使用LINQ to Xml时发生System.Xml.XmlException错误

C# 使用LINQ to Xml时发生System.Xml.XmlException错误,c#,xml,linq,C#,Xml,Linq,我不明白问题出在哪里,尽管这个代码非常简单 我有这样的功能: public void WriteToDoc(string path) { XDocument doc = new XDocument (new XElement("General parameters", new XElement("num_path", num_path.Text

我不明白问题出在哪里,尽管这个代码非常简单

我有这样的功能:

public void WriteToDoc(string path)    
        {
             XDocument doc = new XDocument (new XElement("General parameters",
                                                    new XElement("num_path", num_path.Text),
                                                    new XElement("Gen_Peroid", Gen_Peroid.Text),
                                                    new XElement("Alg_Perioad", Alg_Perioad.Text)
                                                         )
                                          );
            doc.Save(path);
        }
File.Create(@"C:\ProgramData\RadiolocationQ\Q.xml");
WriteToDoc(@"C:\ProgramData\RadiolocationQ\Q.xml");
num\u path.Text
Gen\u Peroid.Text
Alg\u Perioad.Text
都是
string

这是我如何使用此功能的:

public void WriteToDoc(string path)    
        {
             XDocument doc = new XDocument (new XElement("General parameters",
                                                    new XElement("num_path", num_path.Text),
                                                    new XElement("Gen_Peroid", Gen_Peroid.Text),
                                                    new XElement("Alg_Perioad", Alg_Perioad.Text)
                                                         )
                                          );
            doc.Save(path);
        }
File.Create(@"C:\ProgramData\RadiolocationQ\Q.xml");
WriteToDoc(@"C:\ProgramData\RadiolocationQ\Q.xml");

Xml元素不能包含空格。修复XML以符合标准


Xml元素不能包含空格。修复XML以符合标准


异常文本的其余部分是什么?
System.Xml.xmleexception
调用
WriteToDoc
函数时出错。对,但实际的异常文本是什么?不是异常类型吗?异常的
消息是什么?异常文本的其余部分是什么?
System.Xml.xmleexception
调用
WriteToDoc
函数时出错。对,但实际的异常文本是什么?不是异常类型吗?例外情况的
信息是什么?@Rocketq,请务必投票并接受这个答案。祝你好运@Rocketq,请确保投票并接受这个答案。祝你好运