1

我正在尝试使用 XML 编写器将 xml 字符串构建到字符串构建器中。

这是可行的,但返回的字符串在 6134 个字符处被截断。

从我读到的问题在于字符串生成器而不是 xml 编写器。

我试过手动增加它的容量,但这似乎没有任何效果。

这是一些示例代码

StringBuilder xmlout = new StringBuilder(50000000);

using (XmlWriter w = XmlWriter.Create(xmlout))
    {
        w.WriteStartDocument();
        w.WriteStartElement("order");
        w.WriteAttributeString("Name", "Value");

        // more elements and attributes...

        w.WriteEndElement(); //order
        w.WriteEndDocument();
    }

String xml = xmlout.ToString();

我已经投入了非常高的容量作为测试。

任何帮助表示赞赏

4

0 回答 0