我正在用 c# 创建一个 XML 文档。
现在一切都在一起了,但由于某种原因,我不断收到错误消息。
这是我的代码:
FileStream Slide2XmlStream = new FileStream(slide2Xml, FileMode.Create, FileAccess.Write);
XmlWriter slide2XmlWriter = null;
try
{
XmlWriterSettings contentTypesSettings = new XmlWriterSettings();
contentTypesSettings.Indent = true;
slide2XmlWriter = XmlWriter.Create(Slide2XmlStream, contentTypesSettings);
slide2XmlWriter.WriteStartDocument(true);
slide2XmlWriter.WriteStartElement( "p", "sld","http://schemas.openxmlformats.org/presentationml/2006/main" );
slide2XmlWriter.WriteAttributeString("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
slide2XmlWriter.WriteAttributeString( "a","http://schemas.openxmlformats.org/drawingml/2006/main");
slide2XmlWriter.WriteStartElement( "p", "cSld", null);
slide2XmlWriter.WriteStartElement( "p", "spTree", null );
slide2XmlWriter.WriteStartElement( "p", "nvGrpSpPr", null );
slide2XmlWriter.WriteStartElement( "p", "cNvpr", null );
slide2XmlWriter.WriteAttributeString("name", "");
slide2XmlWriter.WriteAttributeString("id", "1");
slide2XmlWriter.WriteEndElement();
slide2XmlWriter.WriteStartElement( "p", "cNvGrpSpPr", null );
slide2XmlWriter.WriteEndElement();
slide2XmlWriter.WriteStartElement( "p", "nvPr", null );
slide2XmlWriter.WriteEndElement();
slide2XmlWriter.WriteEndElement();
slide2XmlWriter.WriteStartElement( "p", "grpSpPr", null );
slide2XmlWriter.WriteStartElement( "a", "xfrm", null );
slide2XmlWriter.WriteStartElement( "a", "off", null );
slide2XmlWriter.WriteAttributeString("y", "0");
slide2XmlWriter.WriteAttributeString("x", "0");
slide2XmlWriter.WriteEndElement();
该错误一直出现在方法开头的“a”前缀上。任何帮助都会得到真正的赞赏。