当前位置: 首页>>代码示例>>C#>>正文


C# XmlWriter.WriteStartDocument方法代码示例

本文整理汇总了C#中System.Xml.XmlWriter.WriteStartDocument方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteStartDocument方法的具体用法?C# XmlWriter.WriteStartDocument怎么用?C# XmlWriter.WriteStartDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlWriter的用法示例。


在下文中一共展示了XmlWriter.WriteStartDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: QueryOutputWriterV1

        public QueryOutputWriterV1(XmlWriter writer, XmlWriterSettings settings)
        {
            _wrapped = writer;

            _systemId = settings.DocTypeSystem;
            _publicId = settings.DocTypePublic;

            if (settings.OutputMethod == XmlOutputMethod.Xml)
            {
                bool documentConformance = false;

                // Xml output method shouldn't output doc-type-decl if system ID is not defined (even if public ID is)
                // Only check for well-formed document if output method is xml
                if (_systemId != null)
                {
                    documentConformance = true;
                    _outputDocType = true;
                }

                // Check for well-formed document if standalone="yes" in an auto-generated xml declaration
                if (settings.Standalone == XmlStandalone.Yes)
                {
                    documentConformance = true;
                    _standalone = settings.Standalone;
                }

                if (documentConformance)
                {
                    if (settings.Standalone == XmlStandalone.Yes)
                    {
                        _wrapped.WriteStartDocument(true);
                    }
                    else
                    {
                        _wrapped.WriteStartDocument();
                    }
                }

                if (settings.CDataSectionElements != null && settings.CDataSectionElements.Count > 0)
                {
                    _bitsCData = new BitStack();
                    _lookupCDataElems = new Dictionary<XmlQualifiedName, XmlQualifiedName>();
                    _qnameCData = new XmlQualifiedName();

                    // Add each element name to the lookup table
                    foreach (XmlQualifiedName name in settings.CDataSectionElements)
                    {
                        _lookupCDataElems[name] = null;
                    }

                    _bitsCData.PushBit(false);
                }
            }
            else if (settings.OutputMethod == XmlOutputMethod.Html)
            {
                // Html output method should output doc-type-decl if system ID or public ID is defined
                if (_systemId != null || _publicId != null)
                    _outputDocType = true;
            }
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:60,代码来源:QueryOutputWriterV1.cs

示例2: WriteBooksToXml

        private static void WriteBooksToXml( XmlWriter writer, List<Book> booklist )
        {
            writer.WriteStartDocument();
              {
            writer.WriteStartElement("bdd", "books", NS); //This adds the root element, <bdd:books>.

            foreach(Book book in booklist) {

              writer.WriteStartElement("bdd", "book", NS); //Adds the element <bdd:book>.
              writer.WriteAttributeString("language", NS, book.Language); //Adding attributes to the element we just started.
              writer.WriteAttributeString("pages", NS, book.Pages);
              {
            writer.WriteElementString("title", NS, book.Title);
            if(book.Subtitle != "")
              writer.WriteElementString("subtitle", NS, book.Subtitle);
            if(book.Authors != null)
              foreach(string author in book.Authors)
                writer.WriteElementString("author", NS, author);
            else
              writer.WriteElementString("author", NS, book.Author);
            writer.WriteElementString("publisher", NS, book.Publisher);
            writer.WriteElementString("year", NS, book.Year);
              }
              writer.WriteEndElement(); //Closes the <bdd:book> element.
            }

            writer.WriteEndElement(); //Closes the <bdd:books> element.
              }
              writer.WriteEndDocument();
        }
开发者ID:jgn-epp,项目名称:Skole,代码行数:30,代码来源:Program.cs

示例3: RdfXmlWriter

 public RdfXmlWriter(XmlWriter writer)
 {
     if (writer == null) throw new ArgumentNullException("writer");
     _writer = writer;
     _writer.WriteStartDocument();
     _writer.WriteStartElement("rdf", "RDF", RdfNamespace);
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:7,代码来源:RdfXmlWriter.cs

示例4: Write

        public static void Write(XmlWriter writer, Ticket pt)
        {
            var declarations = NamespaceDeclarations(pt);

            writer.WriteStartDocument();
            var prefix = declarations.LookupPrefix(Psf.PrintTicket.NamespaceName);
            writer.WriteStartElement(prefix, Psf.PrintTicket.LocalName, Psf.PrintTicket.NamespaceName);
            writer.WriteAttributeString("version", "1");

            foreach (var decl in declarations)
            {
                writer.WriteAttributeString("xmlns", decl.Prefix, null, decl.Uri.NamespaceName);
            }

            foreach (var f in pt.Features())
            {
                Write(writer, f);
            }

            foreach (var p in pt.Properties())
            {
                Write(writer, p);
            }

            foreach (var p in pt.Parameters())
            {
                Write(writer, p);
            }

            writer.WriteEndElement();
            writer.Flush();
        }
开发者ID:kei10in,项目名称:KipSharp,代码行数:32,代码来源:PrintSchemaWriter.cs

示例5: Minimize

        // ----------------------------------------------------------
        public void Minimize(Options aOptions, Def aDef)
        {
            // reader
            _reader = new XmlDocument();
            _reader.Load(aOptions.inFile);

            // writter with write settings
            var writterSettings = new XmlWriterSettings();
            if (aOptions.prettyPrint) {
                writterSettings.Indent = true;
                writterSettings.IndentChars = "  ";
            }
            _writer = XmlWriter.Create(aOptions.outFile, writterSettings);

            _writer.WriteStartDocument();

            ProcessElement(_reader.DocumentElement, aDef);

            _writer.WriteEndDocument();
            _writer.Close();

            // print warnings
            foreach(string warning in _warnings) {
                Console.WriteLine(warning);
            }
        }
开发者ID:SBCGames,项目名称:SpriterMinimizer,代码行数:27,代码来源:XmlMinimizer.cs

示例6: WriteResponseMessage

        public void WriteResponseMessage ( XmlWriter writer, string innerXml, NuxleusAsyncResult asyncResult ) {

            using (writer) {
                writer.WriteStartDocument();
                if (m_responseType == ResponseType.REDIRECT) {
                    writer.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='/service/transform/openid-redirect.xsl'");
                }
                writer.WriteStartElement("auth");
                writer.WriteAttributeString("xml:base", "http://dev.amp.fm/");
                writer.WriteAttributeString("status", m_status);
                if (m_responseType == ResponseType.REDIRECT) {
                    writer.WriteElementString("url", "http://dev.amp.fm/");
                }
                if (m_responseType == ResponseType.QUERY_RESPONSE && innerXml != null) {
                    writer.WriteStartElement("response");
                    writer.WriteRaw(innerXml);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            asyncResult.CompleteCall();

        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:25,代码来源:Message.cs

示例7: Serialize

    /// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary>
    /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
    /// <param name="obj">An <c>Object</c> to serialize.</param>
    /// <seealso cref="XmlRpcResponse"/>
    override public void Serialize(XmlWriter output, Object obj)
      {
	XmlRpcResponse response = (XmlRpcResponse) obj;

	output.WriteStartDocument();
	output.WriteStartElement(METHOD_RESPONSE);

	if (response.IsFault)
	  output.WriteStartElement(FAULT);
	else
	  {
	    output.WriteStartElement(PARAMS);
	    output.WriteStartElement(PARAM);
	  }

	output.WriteStartElement(VALUE);

	SerializeObject(output,response.Value);

	output.WriteEndElement();

	output.WriteEndElement();
	if (!response.IsFault)
	  output.WriteEndElement();
	output.WriteEndElement();
      }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:30,代码来源:XmlRpcResponseSerializer.cs

示例8: SerializeAnalyticsSettings

        /// <summary> 
        /// Write the settings provided to stream 
        /// </summary> 
        /// <param name="inputStream"></param> 
        /// <returns></returns> 
        public static void SerializeAnalyticsSettings(XmlWriter xmlWriter, AnalyticsSettings settings)
        {
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement(SettingsSerializerHelper.RootPropertiesElementName);

            //LOGGING STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.LoggingElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.LogVersion);
            xmlWriter.WriteEndElement();

            bool isReadEnabled = (settings.LogType & LoggingLevel.Read) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeReadElementName);
            xmlWriter.WriteValue(isReadEnabled);
            xmlWriter.WriteEndElement();

            bool isWriteEnabled = (settings.LogType & LoggingLevel.Write) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeWriteElementName);
            xmlWriter.WriteValue(isWriteEnabled);
            xmlWriter.WriteEndElement();

            bool isDeleteEnabled = (settings.LogType & LoggingLevel.Delete) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeDeleteElementName);
            xmlWriter.WriteValue(isDeleteEnabled);
            xmlWriter.WriteEndElement();

            SerializeRetentionPolicy(xmlWriter, settings.IsLogRetentionPolicyEnabled, settings.LogRetentionInDays);
            xmlWriter.WriteEndElement(); // logging element

            //METRICS STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.MetricsVersion);
            xmlWriter.WriteEndElement();

            bool isServiceSummaryEnabled = (settings.MetricsType & MetricsType.ServiceSummary) != MetricsType.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsEnabledElementName);
            xmlWriter.WriteValue(isServiceSummaryEnabled);
            xmlWriter.WriteEndElement();

            if (isServiceSummaryEnabled)
            {
                bool isApiSummaryEnabled = (settings.MetricsType & MetricsType.ApiSummary) != MetricsType.None;
                xmlWriter.WriteStartElement(SettingsSerializerHelper.IncludeApiSummaryElementName);
                xmlWriter.WriteValue(isApiSummaryEnabled);
                xmlWriter.WriteEndElement();
            }

            SerializeRetentionPolicy(
                xmlWriter,
                settings.IsMetricsRetentionPolicyEnabled,
                settings.MetricsRetentionInDays);
            xmlWriter.WriteEndElement();
            // metrics
            xmlWriter.WriteEndElement();
            // root element
            xmlWriter.WriteEndDocument();
        }
开发者ID:flin-aa,项目名称:Windows-Monitoring-Scripts,代码行数:65,代码来源:SettingsSerializerHelper.cs

示例9: WriteDocument

    public virtual void WriteDocument(Stream stream, TagCompound tag, CompressionOption compression)
    {
      bool createWriter;

      if (compression == CompressionOption.On)
      {
        throw new NotSupportedException("Compression is not supported.");
      }

      createWriter = _writer == null;

      if (createWriter)
      {
        XmlWriterSettings settings;

        settings = new XmlWriterSettings
                   {
                     Indent = true,
                     Encoding = Encoding.UTF8
                   };

        _writer = XmlWriter.Create(stream, settings);
        _writer.WriteStartDocument(true);
      }

      this.WriteTag(tag, WriteTagOptions.None);

      if (createWriter)
      {
        _writer.WriteEndDocument();
        _writer.Flush();
        _writer = null;
      }
    }
开发者ID:cyotek,项目名称:Cyotek.Data.Nbt,代码行数:34,代码来源:XmlTagWriter.cs

示例10: WriteXmlLogStart

 public static void WriteXmlLogStart(XmlWriter xw)
 {
     xw.WriteStartDocument();
     xw.WriteStartElement("LogEntries");
     xw.WriteString("\r\n");
     xw.WriteComment(StaticVariables.Logo(false) + "\r\n" + CurrentQuery + "\r\n"); //+ CurrentEntryCount + "\r\n");
 }
开发者ID:BrendanThompson,项目名称:LogQuery,代码行数:7,代码来源:Logs.cs

示例11: Write

        public void Write()
        {
            XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.CloseOutput = true;
            xmlSetting.Encoding = Encoding.UTF8;
            xmlSetting.Indent = true;
            xmlSetting.NewLineChars = "\r\n";

            wr = XmlWriter.Create(GeneralConfig.AppDataPath + "Questionaries\\" + questionary.Category + ".xml", xmlSetting);
            wr.WriteStartDocument();
            wr.WriteStartElement("Questionary");
            wr.WriteStartAttribute("category");
            wr.WriteValue(questionary.Category);
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("created");
            wr.WriteValue(questionary.Created.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("updated");
            wr.WriteValue(questionary.Updated.ToString());
            wr.WriteEndAttribute();

            wr.WriteStartAttribute("template");
            wr.WriteValue(questionary.TemplateId);
            wr.WriteEndAttribute();

            wr.WriteStartElement("Questions");
            WriteQuestions();
            wr.WriteEndElement();

            wr.WriteEndElement();
            wr.WriteEndDocument();
            wr.Close();
        }
开发者ID:foresightbrand,项目名称:kebibi,代码行数:35,代码来源:QuestionaryWriter.cs

示例12: ExecuteResult

    public override void ExecuteResult(ControllerContext context)
    {
      var response = context.HttpContext.Response;
      response.ClearContent();
      response.ContentType = "text/xml";
      response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xml", _exportName));

      var settings = new XmlWriterSettings
        {
          Indent = true,
          Encoding = Encoding.UTF8,
          ConformanceLevel = ConformanceLevel.Document,
          CheckCharacters = true,
          NamespaceHandling = NamespaceHandling.OmitDuplicates
        };
      _writer = XmlWriter.Create(response.OutputStream, settings);
      _writer.WriteStartDocument(true);

      AddItem(_blob, _rootName, true);

      _writer.WriteEndDocument();

      _writer.Flush();
      _writer = null;
    }
开发者ID:glittle,项目名称:TallyJ-v2.0-Archive,代码行数:25,代码来源:Exporter.cs

示例13: Write

        // Private Methods
        //======================================================================

        private void Write(XmlWriter outputWriter)
        {
            outputWriter.WriteStartDocument();

            XStreamingElement root = MakeDzcTree();
            root.WriteTo(outputWriter);
        }
开发者ID:lramctr,项目名称:Lakshmi-Files,代码行数:10,代码来源:DzcSerializer.cs

示例14: Serialize

        public void Serialize(DbDatabaseMapping databaseMapping, DbProviderInfo providerInfo, XmlWriter xmlWriter)
        {
            //Contract.Requires(xmlWriter != null);
            //Contract.Requires(databaseMapping != null);
            //Contract.Requires(providerInfo != null);
            Contract.Assert(databaseMapping.Model != null);
            Contract.Assert(databaseMapping.Database != null);

            _xmlWriter = xmlWriter;
            _databaseMapping = databaseMapping;
            _version = databaseMapping.Model.Version;
            _providerInfo = providerInfo;
            _namespace = _version == DataModelVersions.Version3 ? EdmXmlNamespaceV3 : EdmXmlNamespaceV2;

            _xmlWriter.WriteStartDocument();

            using (Element("Edmx", "Version", string.Format(CultureInfo.InvariantCulture, "{0:F1}", _version)))
            {
                WriteEdmxRuntime();
                WriteEdmxDesigner();
            }

            _xmlWriter.WriteEndDocument();
            _xmlWriter.Flush();
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:25,代码来源:EdmxSerializer.cs

示例15: Serialize

        public void Serialize(DbDatabaseMapping databaseMapping, XmlWriter xmlWriter)
        {
            DebugCheck.NotNull(xmlWriter);
            DebugCheck.NotNull(databaseMapping);
            Debug.Assert(databaseMapping.Model != null);
            Debug.Assert(databaseMapping.Database != null);

            _xmlWriter = xmlWriter;
            _databaseMapping = databaseMapping;
            _version = databaseMapping.Model.SchemaVersion;
            _namespace = Equals(_version, XmlConstants.EdmVersionForV3)
                             ? EdmXmlNamespaceV3
                             : (Equals(_version, XmlConstants.EdmVersionForV2) ? EdmXmlNamespaceV2 : EdmXmlNamespaceV1);

            _xmlWriter.WriteStartDocument();

            using (Element("Edmx", "Version", string.Format(CultureInfo.InvariantCulture, "{0:F1}", _version)))
            {
                WriteEdmxRuntime();
                WriteEdmxDesigner();
            }

            _xmlWriter.WriteEndDocument();
            _xmlWriter.Flush();
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:25,代码来源:EdmxSerializer.cs


注:本文中的System.Xml.XmlWriter.WriteStartDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。