私は、C# からパワー ポイント ドキュメントを作成するプロジェクトに取り組んでいます。なんらかの理由で、私の方法の 1 つで、このエラーが発生しています。
「状態 EndRootElement のトークン StartElement は、無効な XML ドキュメントになります。」
これが私の方法です:
private static void slideLayout6XML()
{
FileStream slideLayout6Stream = new FileStream( slideLayout6, FileMode.Create, FileAccess.Write );
XmlWriter slideLayout6Writer = null;
try
{
XmlWriterSettings contentTypesSettings = new XmlWriterSettings();
contentTypesSettings.Indent = true;
slideLayout6Writer = XmlWriter.Create( slideLayout6Stream, contentTypesSettings );
slideLayout6Writer.WriteStartDocument( true );
slideLayout6Writer.WriteStartElement( "p", "sldLayout" );
slideLayout6Writer.WriteAttributeString( "preserve", "1" );
slideLayout6Writer.WriteAttributeString( "type", "titleOnly" );
slideLayout6Writer.WriteStartElement( "p", "http://schemas.openxmlformats.org/drawingml/2006/main" );
slideLayout6Writer.WriteStartElement( "r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships" );
slideLayout6Writer.WriteStartElement( "a", "http://schemas.openxmlformats.org/presentationml/2006/main" );
slideLayout6Writer.WriteStartElement( "p", "cSld" );
slideLayout6Writer.WriteAttributeString( "name", "Title Only" );
slideLayout6Writer.WriteStartElement( "p", "spTree" );
slideLayout6Writer.WriteStartElement( "p", "nvGrpSpPr" );
slideLayout6Writer.WriteStartElement( "p", "cNvpr" );
slideLayout6Writer.WriteAttributeString( "name", "" );
slideLayout6Writer.WriteAttributeString( "id", "1" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "cNvGrpSpPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "nvPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "grpSpPr" );
slideLayout6Writer.WriteStartElement( "a", "xfrm" );
slideLayout6Writer.WriteStartElement( "a", "off" );
slideLayout6Writer.WriteAttributeString( "y", "0" );
slideLayout6Writer.WriteAttributeString( "x", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "ext" );
slideLayout6Writer.WriteAttributeString( "y", "0" );
slideLayout6Writer.WriteAttributeString( "x", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "chOff" );
slideLayout6Writer.WriteAttributeString( "y", "0" );
slideLayout6Writer.WriteAttributeString( "x", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "chExt" );
slideLayout6Writer.WriteAttributeString( "y", "0" );
slideLayout6Writer.WriteAttributeString( "x", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "sp" );
slideLayout6Writer.WriteStartElement( "p", "nvSpPr" );
slideLayout6Writer.WriteStartElement( "p", "cNvPr" );
slideLayout6Writer.WriteAttributeString( "name", "Title 1" );
slideLayout6Writer.WriteAttributeString( "id", "2" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "cNvSpPr" );
slideLayout6Writer.WriteStartElement( "a", "spLocks" );
slideLayout6Writer.WriteAttributeString( "noGrp", "1" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "nvPr" );
slideLayout6Writer.WriteStartElement( "p", "ph" );
slideLayout6Writer.WriteAttributeString( "type", "title" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "txBody" );
slideLayout6Writer.WriteStartElement( "a", "bodyPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "lstStyle" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "p" );
slideLayout6Writer.WriteStartElement( "a", "r" );
slideLayout6Writer.WriteStartElement( "a", "rPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteAttributeString( "smtClean", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "t" );
slideLayout6Writer.WriteRaw( "Click to edit Master title style" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "endParaRPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "sp" );
slideLayout6Writer.WriteStartElement( "p", "nvSpPr" );
slideLayout6Writer.WriteStartElement( "p", "cNvPr" );
slideLayout6Writer.WriteAttributeString( "name", "Date Placeholder 2" );
slideLayout6Writer.WriteAttributeString( "id", "3" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "cNvSpPr" );
slideLayout6Writer.WriteStartElement( "a", "spLocks" );
slideLayout6Writer.WriteAttributeString( "noGrp", "1" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "nvPr" );
slideLayout6Writer.WriteStartElement( "p", "ph" );
slideLayout6Writer.WriteAttributeString( "type", "dt" );
slideLayout6Writer.WriteAttributeString( "idx", "10" );
slideLayout6Writer.WriteAttributeString( "sz", "half" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "txBody" );
slideLayout6Writer.WriteStartElement( "a", "bodyPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "lstStyle" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "p" );
slideLayout6Writer.WriteStartElement( "a", "fld" );
slideLayout6Writer.WriteAttributeString( "type", "datetime1" );
slideLayout6Writer.WriteAttributeString( "id", "{32E0D616-E0F4-45FD-A59D-58900C81D413}" );
slideLayout6Writer.WriteStartElement( "a", "rPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteAttributeString( "smtClean", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "t" );
slideLayout6Writer.WriteRaw( "5/17/2012" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "endParaRpR" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "sp" );
slideLayout6Writer.WriteStartElement( "p", "nvSpPr" );
slideLayout6Writer.WriteStartElement( "p", "cNvPr" );
slideLayout6Writer.WriteAttributeString( "name", "Footer Placeholder 3" );
slideLayout6Writer.WriteAttributeString( "id", "4" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "cNvSpPr" );
slideLayout6Writer.WriteStartElement( "a", "spLocks" );
slideLayout6Writer.WriteAttributeString( "noGrp", "1" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "nvPr" );
slideLayout6Writer.WriteStartElement( "p", "ph" );
slideLayout6Writer.WriteAttributeString( "type", "ftr" );
slideLayout6Writer.WriteAttributeString( "idx", "11" );
slideLayout6Writer.WriteAttributeString( "sz", "quarter" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "txBody" );
slideLayout6Writer.WriteStartElement( "a", "bodyPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "lstStyle" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "p" );
slideLayout6Writer.WriteStartElement( "a", "r" );
slideLayout6Writer.WriteStartElement( "a", "rPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteAttributeString( "smtClean", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "t" );
slideLayout6Writer.WriteRaw( "Crowded Igloo Business System" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "endParaRPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "sp" );
slideLayout6Writer.WriteStartElement( "p", "nvSpPr" );
slideLayout6Writer.WriteStartElement( "p", "cNvPr" );
slideLayout6Writer.WriteAttributeString( "name", "Slide Number Placeholder 4" );
slideLayout6Writer.WriteAttributeString( "id", "5" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "cNvSpPr" );
slideLayout6Writer.WriteStartElement( "a", "spLocks" );
slideLayout6Writer.WriteAttributeString( "noGrp", "1" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "nvPr" );
slideLayout6Writer.WriteStartElement( "p", "ph" );
slideLayout6Writer.WriteAttributeString( "type", "sldNum" );
slideLayout6Writer.WriteAttributeString( "idx", "12" );
slideLayout6Writer.WriteAttributeString( "sz", "quarter" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "txBody" );
slideLayout6Writer.WriteStartElement( "a", "bodyPr" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "lstStyle" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "p" );
slideLayout6Writer.WriteStartElement( "a", "fld" );
slideLayout6Writer.WriteAttributeString( "type", "slidenum" );
slideLayout6Writer.WriteAttributeString( "id", "{8B131516-2DB0-4AAA-89BA-2724DE07B6A2}" );
slideLayout6Writer.WriteStartElement( "a", "rPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteAttributeString( "smtClean", "0" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "t" );
slideLayout6Writer.WriteRaw( "<#>" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "a", "endParaRPr" );
slideLayout6Writer.WriteAttributeString( "lang", "en-US" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "extLst" );
slideLayout6Writer.WriteStartElement( "p", "ext" );
slideLayout6Writer.WriteAttributeString( "uri", "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}" );
slideLayout6Writer.WriteStartElement( "p14", "creationId", "http://schemas.microsoft.com/office/powerpoint/2010/main" );
slideLayout6Writer.WriteAttributeString( "val", "3805825225" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteStartElement( "p", "clrMapOvr" );
slideLayout6Writer.WriteStartElement( "a", "masterClrMapping" );
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndElement();
slideLayout6Writer.WriteEndDocument();
}
finally
{
if (slideLayout6Writer != null)
slideLayout6Writer.Flush();
slideLayout6Writer.Close();
}
}
大規模なメソッドで申し訳ありませんが、このメソッドではエラーがスローされます。どんな助けでも感謝しますありがとう。