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


C# XmlTextWriter.WriteEndAttribute方法代码示例

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


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

示例1: WriteGestureLog

            public void WriteGestureLog(Dictionary<String, Point3D> gestureDict, string timeStamp)
            {
                using (StringWriter sw = new StringWriter(_sBuilder))
                {
                    using (XmlWriter xmlWriter = new XmlTextWriter(sw))
                    {
                        //START MOVEMENT
                        xmlWriter.WriteStartElement("mov");
                        xmlWriter.WriteStartAttribute("time_stamp");
                        xmlWriter.WriteValue(timeStamp);
                        xmlWriter.WriteEndAttribute();
                        //PRINT ALL JOINTS
                        foreach (var point in gestureDict)
                        {
                            xmlWriter.WriteStartElement(point.Key);//START JOINT
                            xmlWriter.WriteStartElement("x");
                            xmlWriter.WriteValue(point.Value.X);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Y");
                            xmlWriter.WriteValue(point.Value.Y);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteStartElement("Z");
                            xmlWriter.WriteValue(point.Value.Z);
                            xmlWriter.WriteEndElement();
                            xmlWriter.WriteEndElement();//END JOINT
                        }
                        xmlWriter.WriteEndElement();//END MOV
                    }

                }
                WriteToXMLLogFile();
            }
开发者ID:saflogar,项目名称:GestureTrainingInterface,代码行数:32,代码来源:XMLLoggerSingleton.cs

示例2: Main

 public static void Main() {
 StringWriter w = new StringWriter();
 XmlTextWriter x = new XmlTextWriter(w);
 x.Formatting = Formatting.Indented;
 x.WriteStartDocument();
 x.WriteComment("a simple test");
 x.WriteStartElement("message");
 x.WriteStartAttribute("project", "");
 x.WriteString("Rotor");
 x.WriteEndAttribute();
 x.WriteString("Hello world!");
 x.WriteEndElement();
 x.WriteEndDocument();
 x.Flush();
 Console.WriteLine(w.ToString());
 }
开发者ID:ArildF,项目名称:masters,代码行数:16,代码来源:helloxml.cs

示例3: SqlDataReaderToXml


//.........这里部分代码省略.........
        const String NONAME_FIELD_PREFIX = "FIELD";

        int
          i,
          start_field_index   = ASkipNameColumn ? 1 : 0,
          empty_name_field_no = 1;
        String FieldName;

        DataTable LDataTable = AReader.GetSchemaTable();

        List<TFieldAlias> LFields = new List<TFieldAlias>();
        TFieldAlias LField;
        int FieldCount = AReader.FieldCount;

        if(AMap.Fields.Length > 0)
        {
          foreach (String FieldMap in AMap.Fields.Split(new char[] {','}))
          {
        i = FieldMap.IndexOf('=');
        if(i >= 0)
        {
          LField.Name = FieldMap.Substring(0, i);
          FieldName   = FieldMap.Substring(i + 1);
        }
        else
        {
          LField.Name = FieldMap;
          FieldName   = FieldMap;
        }
        for(i = start_field_index; i < FieldCount; i++)
        {
          if(FieldName.Equals(AReader.GetName(i), StringComparison.InvariantCultureIgnoreCase))
            break;
        }
        if((i < 0) || (i >= FieldCount))
          throw new SystemException("RowSet Field = [" + FieldName + "] not found.");
        // LField.Name = XmlConvert.EncodeLocalName(LField.Name);
        LField.FieldIndex = i;
        LFields.Add(LField);

        //AWriter.WriteStartAttribute(LField.Name);
        //AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[i]));
          }
        }
        else
        {
          for(LField.FieldIndex = start_field_index; LField.FieldIndex < FieldCount; LField.FieldIndex++)
          {
        FieldName = AReader.GetName(LField.FieldIndex);
        if(FieldName.Length == 0)
          FieldName = NONAME_FIELD_PREFIX + (empty_name_field_no++).ToString();
        LField.Name = FieldName;
        //LField.Name = XmlConvert.EncodeLocalName(FieldName);
        LFields.Add(LField);

        //AWriter.WriteStartAttribute(LField.Name);
        //AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[LField.FieldIndex]));
          }
        }

        AWriter.WriteStartElement(METADATA_TAG);
        for (i = 0; i < LFields.Count; i++)
        {
          AWriter.WriteStartElement(FIELD_TAG);
        AWriter.WriteStartAttribute(ATTRIBUTE_INDEX);
        AWriter.WriteValue(i + 1);
        AWriter.WriteStartAttribute(ATTRIBUTE_NAME);
        AWriter.WriteValue(LFields[i].Name);
        AWriter.WriteStartAttribute(ATTRIBUTE_TYPE);
        AWriter.WriteValue(SqlMetaDataToString(LDataTable.Rows[LFields[i].FieldIndex]));
          AWriter.WriteEndElement();
        }
        AWriter.WriteEndElement();

        object Value;
        while (AReader.Read())
        {
          AWriter.WriteStartElement(ARowTag ?? ROW_TAG);

          for (i = 0; i < LFields.Count; i++)
          {
        Value = AReader.GetValue(LFields[i].FieldIndex);
        if (Value != DBNull.Value) // NULL пропускаем
        {
          AWriter.WriteStartAttribute(XmlConvert.EncodeLocalName(LFields[i].Name));
          try
          {
            AWriter.WriteValue(Value);
          }
          catch (InvalidCastException)
          {
            AWriter.WriteValue(Value.ToString());
          }

          AWriter.WriteEndAttribute();
        }
          }
          AWriter.WriteEndElement();
        }
    }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:101,代码来源:Sql.UDP.GetResult.cs

示例4: SaveMap

    /// <summary>
    /// Save the map to file.
    /// </summary>
    /// <param name="filename">
    /// A <see cref="System.String"/>
    /// </param>
    private void SaveMap(string filename)
    {
        //XML file
        string xmlFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".xml");
        //Tile data file
        //string tdFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".td");

        Log.Write("Saving current map to XML " + xmlFile);

        XmlWriter xmlWriter = new XmlTextWriter(xmlFile, new System.Text.UTF8Encoding());

        xmlWriter.WriteStartDocument();
        xmlWriter.WriteWhitespace("\r\n");
        xmlWriter.WriteStartElement("map");
        xmlWriter.WriteStartAttribute("id");
        xmlWriter.WriteValue(model.MapID);
        xmlWriter.WriteEndAttribute();

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("geometry");

        //Write dimensions
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("width");
        xmlWriter.WriteValue(model.TileMap.Width);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("height");
        xmlWriter.WriteValue(model.TileMap.Height);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("layers");
        xmlWriter.WriteValue(model.TileMap.Layers);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("tilesize");
        xmlWriter.WriteValue(model.TileMap.Tilesize);
        xmlWriter.WriteEndElement();

        //Offsets
        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("xoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetX);
        xmlWriter.WriteEndElement();

        xmlWriter.WriteWhitespace("\r\n\t\t");
        xmlWriter.WriteStartElement("yoffset");
        xmlWriter.WriteValue(model.TileMap.OffsetY);
        xmlWriter.WriteEndElement();

        //Geometry end
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Tileset
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("tileset");
        {

            bool foundTileset = false;
            foreach (string tsName in model.ResourceManager.Tilesets)
            {
                Tileset ts = model.ResourceManager.GetTileset(tsName);
                if (ts == model.CurrentTileset)
                {
                    xmlWriter.WriteValue(tsName);
                    foundTileset = true;
                    break;
                }
            }
            if (!foundTileset)
            {
                throw new NotFoundException("Tileset was not found in resource manager. This should not happen! What did you do?");
            }
        }

        xmlWriter.WriteEndElement();

        //Background
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("background");
        xmlWriter.WriteValue(model.Background);
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\r\n");

        //Extra properties
        xmlWriter.WriteWhitespace("\r\n\t");
        xmlWriter.WriteStartElement("properties");
        foreach (KeyValuePair<string, string> o in model.ExtraProperties)
//.........这里部分代码省略.........
开发者ID:hallgeirl,项目名称:Hiage,代码行数:101,代码来源:MainWindow.cs

示例5: WriteExampleAttribute

    } //WriteExampleAttributes()

    // Write a single example attribute
    public static void WriteExampleAttribute(XmlSchemaAttribute attribute, XmlTextWriter myXmlTextWriter)
    {
      myXmlTextWriter.WriteStartAttribute(attribute.QualifiedName.Name, attribute.QualifiedName.Namespace);
      // The examples value
      WriteExampleValue(attribute.AttributeType, myXmlTextWriter);
      myXmlTextWriter.WriteEndAttribute();
    } //WriteExampleAttribute()
开发者ID:ArildF,项目名称:masters,代码行数:10,代码来源:xmlschema.cs

示例6: WriteXmlSchemaElement

    } //WriteXmlSchemaParticle()

    // XmlSchemaElement
    public static void WriteXmlSchemaElement(XmlSchemaElement element, XmlSchema myXmlSchema, XmlTextWriter myXmlTextWriter)
    {
      myXmlTextWriter.WriteStartElement("element", XmlSchema.Namespace);
      if (element.Name != null)
      {
        myXmlTextWriter.WriteAttributeString("name", element.Name);
      }//if

      if (!element.RefName.IsEmpty)
      {
        myXmlTextWriter.WriteStartAttribute("ref", null);
        myXmlTextWriter.WriteQualifiedName(element.RefName.Name, element.RefName.Namespace);
        myXmlTextWriter.WriteEndAttribute();
      } //if

      if (!element.SchemaTypeName.IsEmpty)
      {
        myXmlTextWriter.WriteStartAttribute("type", null);
        myXmlTextWriter.WriteQualifiedName(element.SchemaTypeName.Name, element.SchemaTypeName.Namespace);
        myXmlTextWriter.WriteEndAttribute();
      } //if

      if (element.SchemaType != null)
      {
        if (element.SchemaType is XmlSchemaComplexType)
          WriteXmlSchemaComplexType((XmlSchemaComplexType)element.SchemaType, myXmlSchema, myXmlTextWriter);
        else
          WriteXmlSchemaSimpleType((XmlSchemaSimpleType)element.SchemaType, myXmlTextWriter);
      } //if
      myXmlTextWriter.WriteEndElement();
    } //WriteXmlSchemaElement()
开发者ID:ArildF,项目名称:masters,代码行数:34,代码来源:xmlschema.cs

示例7: WriteXmlSchemaAttribute

    } //WriteXSDSchema()

    /// <summary>
    /// This method writes out an XML schema attribute.
    /// </summary>
    /// <param name="attribute">XML schema attribute to be output.</param>
    /// <param name="myXmlTextWriter">XmlTextWriter to write output to.</param>
    public static void WriteXmlSchemaAttribute(XmlSchemaAttribute attribute, XmlTextWriter myXmlTextWriter)
    {
      myXmlTextWriter.WriteStartElement("attribute", XmlSchema.Namespace);
      if (attribute.Name != null)
      {
        myXmlTextWriter.WriteAttributeString("name", attribute.Name);
      } //if

      if (!attribute.RefName.IsEmpty)
      {
        myXmlTextWriter.WriteStartAttribute("ref", null);
        myXmlTextWriter.WriteQualifiedName(attribute.RefName.Name, attribute.RefName.Namespace);
        myXmlTextWriter.WriteEndAttribute();
      } //if

      if (!attribute.SchemaTypeName.IsEmpty)
      {
        myXmlTextWriter.WriteStartAttribute("type", null);
        myXmlTextWriter.WriteQualifiedName(attribute.SchemaTypeName.Name, attribute.SchemaTypeName.Namespace);
        myXmlTextWriter.WriteEndAttribute();
      } //if

      if (attribute.SchemaType != null)
      {
        WriteXmlSchemaSimpleType(attribute.SchemaType, myXmlTextWriter);
      } //if

      myXmlTextWriter.WriteEndElement();
    } //WriteXmlSchemaAttribute()
开发者ID:ArildF,项目名称:masters,代码行数:36,代码来源:xmlschema.cs

示例8: Index

    public void Index()
    {
       
            //SEARCHING FOR DIRECTORIES IN ASSETS DIRECTORY, WHICH ARE THEMES
            //string searchPath = Path.Combine(HttpRuntime.AppDomainAppVirtualPath, "Assets");
            string searchPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Assets");
            string[] dirs = Directory.GetDirectories(searchPath, "*");
            List<int> ids = new List<int>();

            foreach (string dir in dirs)
            {
                int directoryId;
                if (int.TryParse(new DirectoryInfo(dir).Name, out directoryId))
                {
                    ids.Add(Convert.ToInt32(new DirectoryInfo(dir).Name));
                }
            }

            var stages = ServerModel.DB.Load<TblResources>("CourseRef", ids);
            string xmlindex = Path.Combine(HttpRuntime.AppDomainAppPath, "tomcat-solr\\apache-solr-1.4.0\\Iudico\\");

        try
        {            
            //DELETING PREVIOUS CREATING XMLs
            string[] filePaths = Directory.GetFiles(xmlindex, "*.xml");
            foreach (string filePath in filePaths)
            {
                File.Delete(filePath);
            }


            //DELETING SOLR INDEX
            HttpWebRequest request = WebRequest.Create("http://localhost:8080/apache-solr-1.4.0/update?stream.body=%3Cdelete%3E%3Cquery%3Ename:*%3C/query%3E%3C/delete%3E") as HttpWebRequest;
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            { }

            HttpWebRequest requestCommit = WebRequest.Create("http://localhost:8080/apache-solr-1.4.0/update?stream.body=%3Ccommit/%3E") as HttpWebRequest;
            using (HttpWebResponse response = requestCommit.GetResponse() as HttpWebResponse)
            { }

        }
        catch (Exception ex)
        {
            if (ex.Message.ToString() == "Unable to connect to the remote server")
            {
                System.Diagnostics.Process procTomcat = new System.Diagnostics.Process();
                procTomcat.EnableRaisingEvents = false;
                procTomcat.StartInfo.FileName = Path.Combine(HttpRuntime.AppDomainAppPath, "tomcat-solr\\tomcatStart.bat");
                procTomcat.Start();
            }
        }

        //CREATING NEW INDEX
        string filename = "";
        int i = 0;
        XmlTextWriter writer;

        try
        {
            foreach (TblResources res in stages)
            {
                i++;

                filename = "XML" + i.ToString() + DateTime.Now.TimeOfDay.Hours.ToString() + DateTime.Now.TimeOfDay.Minutes.ToString() + DateTime.Now.TimeOfDay.Seconds.ToString() + ".xml";

                //CREATING XML WITH ID, NAME AND CONTENT OF THEME
                writer = new XmlTextWriter(xmlindex + filename, null);
                writer.WriteStartElement("add");
                writer.WriteStartElement("doc");
                writer.WriteStartElement("field");
                writer.WriteStartAttribute("name");
                writer.WriteString("id");
                writer.WriteEndAttribute();
                writer.WriteString(res.CourseRef.ToString());
                writer.WriteEndElement();

                var stages2 = ServerModel.DB.Load<TblCourses>(res.CourseRef);

                string name = stages2.Name;

                writer.WriteStartElement("field");
                writer.WriteStartAttribute("name");
                writer.WriteString("name");
                writer.WriteEndAttribute();
                writer.WriteString(name);
                writer.WriteEndElement();

                string filePath = Path.Combine(CourseManager.GetCoursePath(res.CourseRef), res.Href.ToString());
                FileStream file = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read);
                StreamReader sr = new StreamReader(file);
                string s = sr.ReadToEnd();
                sr.Close();
                file.Close();

                IHTMLDocument2 doc = new HTMLDocumentClass();
                doc.write(new object[] { s });
                doc.close();

                writer.WriteStartElement("field");
                writer.WriteStartAttribute("name");
//.........这里部分代码省略.........
开发者ID:supermuk,项目名称:iudico,代码行数:101,代码来源:IndexData.cs

示例9: WriteNode

	public static void WriteNode(XmlElement node, string method, XmlTextWriter output, TextWriter raw) {
		if (node.Name == "string") {
			output.WriteString(node.InnerText);
			return;
		}
		
		if (node.Name == "Attribute")
			output.WriteStartAttribute(node.GetAttribute("Name"), "");
		else if (node.Name == "Text") {
		}
		else if (node.Name != "Element")
			output.WriteStartElement(node.Name);
		else
			output.WriteStartElement(node.GetAttribute("Name"));
		
		foreach (XmlElement child in node.SelectNodes("*")) {
			string status = child.GetAttribute("Status");
			if (status == "") {
				WriteNode(child, method, output, raw);
			} else if (status == "Same") {
				WriteNodeRaw(child, method, output);
			} else if (status == "Added" || status == "Removed") {
				output.Flush();
				if (method == "text") {
					if (status == "Added") raw.Write("\n+"); else raw.Write("\n-");
				} else if (method == "groff") {
					if (status == "Added") raw.Write("\\m[blue]"); else raw.Write("\\m[red]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n");
				} else if (method == "groff") {
					if (status == "Added") raw.Write("\\m[]"); else raw.Write("\\m[]");
				}
				raw.Flush();
			} else if (status == "Changed") {
				output.Flush();
				if (method == "text") {
					raw.Write("\n-");
				} else if (method == "groff") {
					raw.Write("\\m[green]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n+");
				} else if (method == "groff") {
					raw.Write("\\m[]\\m[magenta]");
				}
				raw.Flush();
				
				WriteNodeRaw((XmlElement)child.FirstChild.NextSibling, method, output);

				output.Flush();
				if (method == "text") {
					raw.Write("\n");
				} else if (method == "groff") {
					raw.Write("\\m[]");
				}
				raw.Flush();
			} else {
				throw new InvalidOperationException("Bad status: " + status);
			}
		}

		if (node.FirstChild is XmlText)
			output.WriteString(node.FirstChild.Value);		
		
		if (node.Name == "Attribute")
			output.WriteEndAttribute();
		else if (node.Name == "Text")
		{}
		else
			output.WriteEndElement();
	}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:82,代码来源:XmlDiff.cs


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