本文整理汇总了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;
}
}
示例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();
}
示例3: RdfXmlWriter
public RdfXmlWriter(XmlWriter writer)
{
if (writer == null) throw new ArgumentNullException("writer");
_writer = writer;
_writer.WriteStartDocument();
_writer.WriteStartElement("rdf", "RDF", RdfNamespace);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
}
示例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");
}
示例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();
}
示例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;
}
示例13: Write
// Private Methods
//======================================================================
private void Write(XmlWriter outputWriter)
{
outputWriter.WriteStartDocument();
XStreamingElement root = MakeDzcTree();
root.WriteTo(outputWriter);
}
示例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();
}
示例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();
}