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


C# XmlWriter.WriteStartElement方法代码示例

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


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

示例1: WriteTo

 public static void WriteTo(XmlWriter xw, IEnumerable<SAMAlignedItem> queries)
 {
   xw.WriteStartElement("queries");
   foreach (var q in queries)
   {
     xw.WriteStartElement("query");
     xw.WriteAttributeString("name", q.Qname);
     xw.WriteAttributeString("sequence", q.Sequence);
     xw.WriteAttributeString("count", q.QueryCount.ToString());
     if (!string.IsNullOrEmpty(q.Sample))
     {
       xw.WriteAttributeString("sample", q.Sample);
     }
     foreach (var l in q.Locations)
     {
       xw.WriteStartElement("location");
       xw.WriteAttributeString("seqname", l.Seqname);
       xw.WriteAttributeString("start", l.Start.ToString());
       xw.WriteAttributeString("end", l.End.ToString());
       xw.WriteAttributeString("strand", l.Strand.ToString());
       xw.WriteAttributeString("cigar", l.Cigar);
       xw.WriteAttributeString("score", l.AlignmentScore.ToString());
       xw.WriteAttributeString("mdz", l.MismatchPositions);
       xw.WriteAttributeString("nmi", l.NumberOfMismatch.ToString());
       xw.WriteAttributeString("nnpm", l.NumberOfNoPenaltyMutation.ToString());
       xw.WriteEndElement();
     }
     xw.WriteEndElement();
   }
   xw.WriteEndElement();
 }
开发者ID:shengqh,项目名称:CQS.Core,代码行数:31,代码来源:SAMAlignedItemUtils.cs

示例2: WriteProjectStatus

	    private static void WriteProjectStatus(XmlWriter xmlWriter, ProjectStatus status, IServerSpecifier serverSpecifier)
	    {
	        xmlWriter.WriteStartElement("Project");
	        xmlWriter.WriteAttributeString("name", status.Name);
	        xmlWriter.WriteAttributeString("category", status.Category);
	        xmlWriter.WriteAttributeString("activity", status.Activity.ToString());
	        xmlWriter.WriteAttributeString("lastBuildStatus", status.BuildStatus.ToString());
	        xmlWriter.WriteAttributeString("lastBuildLabel", status.LastSuccessfulBuildLabel);
	        xmlWriter.WriteAttributeString("lastBuildTime", XmlConvert.ToString(status.LastBuildDate, XmlDateTimeSerializationMode.Local));
	        xmlWriter.WriteAttributeString("nextBuildTime", XmlConvert.ToString(status.NextBuildTime, XmlDateTimeSerializationMode.Local));
	        xmlWriter.WriteAttributeString("webUrl", status.WebURL);
            xmlWriter.WriteAttributeString("CurrentMessage", status.CurrentMessage);
            xmlWriter.WriteAttributeString("BuildStage", status.BuildStage);
            xmlWriter.WriteAttributeString("serverName", serverSpecifier.ServerName);
            xmlWriter.WriteAttributeString("description", status.Description);

            xmlWriter.WriteStartElement("messages");

            foreach (Message m in status.Messages)
            {
                xmlWriter.WriteStartElement("message");
                xmlWriter.WriteAttributeString("text", m.Text);
                xmlWriter.WriteAttributeString("kind", m.Kind.ToString());
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();

	        xmlWriter.WriteEndElement();
	    }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:30,代码来源:XmlReportAction.cs

示例3: WriteReportFieldsXml

        private static void WriteReportFieldsXml(XmlWriter writer, Report report)
        {
            writer.WriteStartElement("Fields");

            foreach (var field in report.Fields.Where(field => field.FieldType != FieldType.SectionRepeater))
            {
                writer.WriteStartElement("Field-" + field.FieldType);
                writer.WriteAttributeString("Label", field.Label);

                if (field.FieldType != FieldType.CheckList && field.FieldType != FieldType.Location)
                {
                    writer.WriteString(field.Value);
                }
                else
                {
                    foreach (var item in field.ChildItems)
                    {
                        writer.WriteElementString(item.Item, item.Value);
                    }
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
开发者ID:gael-ltd,项目名称:gaelenlighten-platform-samples,代码行数:26,代码来源:TransformHelper.cs

示例4: WriteClaimsIdentity

        private void WriteClaimsIdentity( ClaimsIdentity ci, XmlWriter writer )
        {
            writer.WriteStartElement( "ClaimsIdentity" );
            writer.WriteAttributeString( "Name", ci.Name );
            writer.WriteAttributeString( "NameClaimType", ci.NameClaimType );
            writer.WriteAttributeString( "RoleClaimType", ci.RoleClaimType );
            writer.WriteAttributeString( "Label", ci.Label );

            if ( ci.Actor != null )
            {
                writer.WriteStartElement( "Actor" );
                WriteClaimsIdentity( ci.Actor, writer );
                writer.WriteEndElement();
            }

            foreach ( Claim c in ci.Claims )
            {
                writer.WriteStartElement( "Claim" );
                writer.WriteAttributeString( "Value", c.Value );
                writer.WriteAttributeString( "Type", c.Type );
                writer.WriteAttributeString( "ValueType", c.ValueType );
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ClaimsPrincipalTraceRecord.cs

示例5: DoWrite

 protected override void DoWrite(XmlWriter writer, Object obj, IXmlRpcStreamConfig config, ITypeSerializerFactory typeSerializerFactory)
 {
     writer.WriteStartElement(XmlRpcSpec.VALUE_TAG);
     writer.WriteStartElement(XmlRpcSpec.EXTENSIONS_PREFIX, XmlRpcSpec.NIL_TAG, XmlRpcSpec.EXTENSIONS_URI);
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
开发者ID:longshine,项目名称:EasyWeb.NET,代码行数:7,代码来源:NullSerializer.cs

示例6: Write

        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            var csRoot = project.RootDirectory.GetChildDirectory("cs");
            if (csRoot != null)
            {
                var serviceReferencesRoot = csRoot.GetChildDirectory("Service References");
                if (serviceReferencesRoot != null)
                {
                    writer.WriteStartElement("ItemGroup");

                    writer.WriteStartElement("WCFMetadata");
                    writer.WriteAttributeString("Include", "Service References" + Path.DirectorySeparatorChar);
                    writer.WriteEndElement();

                    foreach (var child in serviceReferencesRoot.ChildDirectories)
                    {
                        writer.WriteStartElement("WCFMetadataStorage");
                        writer.WriteAttributeString("Include", "Service References\\" + child + Path.DirectorySeparatorChar);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                }
            }
        }
开发者ID:vigoo,项目名称:bari,代码行数:31,代码来源:WCFMetadataSection.cs

示例7: Write

        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            writer.WriteStartElement("PropertyGroup");
            writer.WriteAttributeString("Condition", " '$(Configuration)|$(Platform)' == 'Bari|Bari' ");
            WriteConfigurationSpecificPart(writer, project);
            writer.WriteEndElement();

            writer.WriteStartElement("PropertyGroup");

            // Writing out configuration specific part to the non conditional block as well
            WriteConfigurationSpecificPart(writer, project);

            writer.WriteElementString("OutputType", GetOutputType(project.Type));
            writer.WriteElementString("AssemblyName", project.Name);
            writer.WriteElementString("ProjectGuid", projectGuidManagement.GetGuid(project).ToString("B"));

            CsharpProjectParameters parameters = project.GetInheritableParameters<CsharpProjectParameters, CsharpProjectParametersDef>("csharp");

            parameters.FillProjectSpecificMissingInfo(project);
            parameters.ToCsprojProperties(writer);

            WriteAppConfig(writer, project);
            WriteManifest(writer, project);
            WriteApplicationIcon(writer, project, parameters);

            writer.WriteEndElement();
        }
开发者ID:vigoo,项目名称:bari,代码行数:33,代码来源:PropertiesSection.cs

示例8: ToXml

        // Originally this class used the XML attributes to serialize itself
        // via an XmlSerializer, but that turns out not the work (see the comments
        // in EventWriter). So instead we have localized all the XML related code
        // in this one method. It turns out to be simpler to understand, too.
        public void ToXml(XmlWriter writer)
        {
            Contract.Requires(writer != null);

            writer.WriteStartElement("event");
            if (Stanza != null) writer.WriteAttributeString("stanza", Stanza);
            if (Unbroken) writer.WriteAttributeString("unbroken", "1");

            if (Data != null) WriteTextElement(writer, "data", Data);
            if (Source != null) WriteTextElement(writer, "source", Source);
            if (SourceType != null) WriteTextElement(writer, "sourcetype", SourceType);
            if (Index != null) WriteTextElement(writer, "index", Index);
            if (Host != null) WriteTextElement(writer, "host", Host);

            if (Time.HasValue)
            {
                double timestamp = (double)(Time.Value.Ticks - ticksSinceEpoch) / TimeSpan.TicksPerSecond;
                writer.WriteStartElement("time");
                writer.WriteString(timestamp.ToString());
                writer.WriteEndElement();
            }

            if (Done)
            {
                writer.WriteStartElement("done");
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
开发者ID:Netsuye,项目名称:Splunk-SDK,代码行数:34,代码来源:Event.cs

示例9: GetDirectoryItemsWithXmlWriter

        static void GetDirectoryItemsWithXmlWriter(string path, XmlWriter writer)
        {
            var dirInfo = new DirectoryInfo(path);

            var files = dirInfo.GetFiles();
            var subdirs = dirInfo.GetDirectories();

            writer.WriteStartElement("dir");
            writer.WriteStartAttribute("name");
            writer.WriteValue(dirInfo.Name);
            writer.WriteEndAttribute();

            foreach (var file in files)
            {
                writer.WriteStartElement("file");
                writer.WriteStartAttribute("name");
                writer.WriteValue(file.Name);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }

            foreach (var dir in subdirs)
            {
                GetDirectoryItemsWithXmlWriter(dir.FullName, writer);
            }

            writer.WriteEndElement();
        }
开发者ID:VladimirDimov,项目名称:DataBases_HW,代码行数:28,代码来源:Program.cs

示例10: 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

示例11: WriteXmlInnerError

 private static void WriteXmlInnerError(XmlWriter writer, ODataInnerError innerError, string innerErrorElementName, int recursionDepth, int maxInnerErrorDepth)
 {
     recursionDepth++;
     if (recursionDepth > maxInnerErrorDepth)
     {
         throw new ODataException(Strings.ValidationUtils_RecursionDepthLimitReached(maxInnerErrorDepth));
     }
     writer.WriteStartElement("m", innerErrorElementName, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
     string text = innerError.Message ?? string.Empty;
     writer.WriteStartElement("message", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
     writer.WriteString(text);
     writer.WriteEndElement();
     string str2 = innerError.TypeName ?? string.Empty;
     writer.WriteStartElement("type", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
     writer.WriteString(str2);
     writer.WriteEndElement();
     string str3 = innerError.StackTrace ?? string.Empty;
     writer.WriteStartElement("stacktrace", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
     writer.WriteString(str3);
     writer.WriteEndElement();
     if (innerError.InnerError != null)
     {
         WriteXmlInnerError(writer, innerError.InnerError, "internalexception", recursionDepth, maxInnerErrorDepth);
     }
     writer.WriteEndElement();
 }
开发者ID:nickchal,项目名称:pash,代码行数:26,代码来源:ErrorUtils.cs

示例12: WriteValue

		protected override void WriteValue(XmlWriter writer, object value)
		{
			IDictionary dictionary = (IDictionary) value;
			foreach (object key in dictionary.Keys)
			{
				object target = dictionary[key];

				// any way to refactor code block?
				ReflectorTypeAttribute typeAttribute = ReflectorTypeAttribute.GetAttribute(target);
				if (typeAttribute == null)
				{
					writer.WriteStartElement(elementName);
					writer.WriteAttributeString(attribute.Key, key.ToString());
					writer.WriteString(target.ToString());
					writer.WriteEndElement();
				}
				else
				{
					writer.WriteStartElement(typeAttribute.Name);
					writer.WriteAttributeString(attribute.Key, key.ToString());

					XmlTypeSerialiser serialiser = (XmlTypeSerialiser) typeAttribute.CreateSerialiser(target.GetType());
					serialiser.WriteMembers(writer, target);

					writer.WriteEndElement();
				}
			}
		}
开发者ID:modulexcite,项目名称:NetReflector,代码行数:28,代码来源:XmlDictionarySerialiser.cs

示例13: WriteTo

		void WriteTo (XmlWriter writer)
		{
			writer.WriteStartElement (Node);
			if (NodeName != null)
				writer.WriteAttributeString (nameAttribute, NodeName);
			if (Expanded)
				writer.WriteAttributeString (expandedAttribute, bool.TrueString);
			if (Selected)
				writer.WriteAttributeString (selectedAttribute, bool.TrueString);

			if (Options != null) {
				foreach (var opt in Options) {
					writer.WriteStartElement ("Option");
					writer.WriteAttributeString ("id", opt.Key.ToString());
					writer.WriteAttributeString ("value", opt.Value.ToString ());
					writer.WriteEndElement (); // Option
				}
			}
			
			if (ChildrenState != null) { 
				foreach (NodeState ces in ChildrenState) {
					ces.WriteTo (writer);
				}
			}
			
			writer.WriteEndElement (); // NodeState
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:27,代码来源:NodeState.cs

示例14: WriteAlbum

        private static void WriteAlbum(XmlWriter writer, string name, string artist, short year, string producer,
            decimal price, List<string> songs = null)
        {
            if (year > 2013)
            {
                throw new ArgumentOutOfRangeException("Impossible year value.");
            }

            if (price < 0)
            {
                throw new ArgumentOutOfRangeException("Impossible price value.");
            }

            writer.WriteStartElement("album");
            writer.WriteElementString("name", name);
            writer.WriteElementString("artist", artist);
            writer.WriteElementString("year", year.ToString());
            writer.WriteElementString("producer", producer);
            writer.WriteElementString("price", string.Format(culture, "{0:C}", price));
            if ((songs != null) && (songs.Count > 0))
            {
                writer.WriteStartElement("songs");
                foreach (var song in songs)
                {
                    writer.WriteElementString("song", song);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
开发者ID:PetarPenev,项目名称:Telerik,代码行数:32,代码来源:Program.cs

示例15: WriteXml

		internal override void WriteXml(XmlWriter writer)
		{
			if (base.IsSlot)
			{
                writer.WriteStartElement("Property", NodeQuery.XmlNamespace);
				writer.WriteAttributeString("name", base.PropertySlot.Name);
				writer.WriteEndElement();
			}
			else if (!IsValue)
			{
                writer.WriteStartElement("Property", NodeQuery.XmlNamespace);
				writer.WriteAttributeString("name", base.NodeAttribute.ToString());
				writer.WriteEndElement();
			}
			else
			{
				if (_value == null)
                    writer.WriteElementString("NullValue", NodeQuery.XmlNamespace, null);
				else if (_value is string)
					writer.WriteString((string)_value);
				else if (_value is int)
					writer.WriteString(XmlConvert.ToString((int)_value));
				else if (_value is decimal)
					writer.WriteString(XmlConvert.ToString((decimal)_value));
				if (_value is DateTime)
					writer.WriteString(XmlConvert.ToString((DateTime)_value, XmlDateTimeSerializationMode.Unspecified));
			}

		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:29,代码来源:Literal.cs


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