[英]problems with converting string which contains xml code into XmlTextWriter
I have a string
variable Writer
that recieves xml code from another window
.我有一个
string
变量Writer
,它从另一个window
接收 xml 代码。 I need to pass this string
to textWriter
variable but i dont know how to make it readable by textWriter
.我需要将此
string
传递给textWriter
变量,但我不知道如何使它可以被textWriter
读取。 I tried to convert it to XmlTextWriter
but it dont seem to work.我试图将它转换为
XmlTextWriter
但它似乎不起作用。 How can it be accepted by textWriter
?它如何被
textWriter
接受?
textWriter = (XmlTextWriter)XmlTextWriter.Create(new StringBuilder(Writer));
XmlTextWriter textWriter;
public Question_Redactor(int k, string Writer)
{
textWriter = new XmlTextWriter(Writer);
InitializeComponent();
}
When the code runs, the following error message is generated:代码运行时,会生成以下错误消息:
The system.InvalidCastException: "Unable to cast objects of type" System.
system.InvalidCastException:“无法转换类型的对象”系统。 Xml.
Xml。 XmlWellFormedWriter "to type" System.
XmlWellFormedWriter "to type" 系统。 Xml.
Xml。 XmlTextWriter"."
XmlTextWriter"。"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.