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


C# XmlTextReader.MoveToAttribute方法代码示例

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


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

示例1: Mirror

    public Mirror(string spec)
    {
        objectStack = new Stack();
        objectStack.Push(null);

        // Register the commands
        commands = new List<Command>();
        commands.Add(new ElementCommand());
        commands.Add(new EndElementCommand());
        commands.Add(new AttributeCommand());

        Reader = new XmlTextReader(spec);
        while (Reader.Read())
        {
            InterpretCommands();

            var b = Reader.IsEmptyElement;
            if (Reader.HasAttributes)
            {
                for (var i = 0; i < Reader.AttributeCount; i++)
                {
                    Reader.MoveToAttribute(i);
                    InterpretCommands();
                }
            }
            if (b) Pop();
        }
    }
开发者ID:david--liu,项目名称:code_kata,代码行数:28,代码来源:Mirror.cs

示例2: PlatformBuildSettings

    public PlatformBuildSettings(XmlTextReader reader)
    {
        textureSettings = new List<TextureAssetSettings>(20);

        if(reader.MoveToAttribute("name"))
            platform = (Platform) System.Enum.Parse(typeof(Platform), reader.Value);
        while(reader.Read()) {
            if(reader.NodeType == XmlNodeType.EndElement && reader.Name == "Platform") {
                reader.ReadEndElement();
                break;
            }
            if(reader.NodeType == XmlNodeType.Element && reader.Name == "TextureAsset") {
                textureSettings.Add(new TextureAssetSettings(reader));
            }
        }
    }
开发者ID:azanium,项目名称:TruthNIslam-Unity,代码行数:16,代码来源:PlatformBuildSettings.cs

示例3: TextureAssetSettings

 public TextureAssetSettings(XmlTextReader reader)
 {
     if(reader.MoveToAttribute("path"))
         path = reader.Value;
     while(reader.Read()) {
         if(reader.NodeType == XmlNodeType.EndElement && reader.Name == "TextureAsset") {
             reader.ReadEndElement();
             break;
         }
         if(reader.NodeType == XmlNodeType.Element && reader.Name == "maxSize") {
             maxSize = int.Parse(reader.ReadInnerXml());
         } else if(reader.NodeType == XmlNodeType.Element && reader.Name == "format") {
             format = (TextureImporterFormat) System.Enum.Parse(typeof(TextureImporterFormat), reader.ReadInnerXml());
         } else if(reader.NodeType == XmlNodeType.Element && reader.Name == "mipmaps") {
             mipmaps = bool.Parse(reader.ReadInnerXml());
         } else if(reader.NodeType == XmlNodeType.Element && reader.Name == "npotScale") {
             npotScale = (TextureImporterNPOTScale) System.Enum.Parse(typeof(TextureImporterNPOTScale), reader.ReadInnerXml());
         }
     }
 }
开发者ID:azanium,项目名称:TruthNIslam-Unity,代码行数:20,代码来源:TextureAssetSettings.cs

示例4: Parse

 // we have to write this method ourselves, since it's
 // not provided by the API
 public virtual void Parse(string url)
 {
     try
     {
         XmlTextReader reader = new XmlTextReader(url);
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
                     string namespaceURI = reader.NamespaceURI;
                     string name = reader.Name;
                     Dictionary<String, String> att = new Dictionary<String, String>();
                     if (reader.HasAttributes)
                     {
                         for (int i = 0; i < reader.AttributeCount; i++)
                         {
                             reader.MoveToAttribute(i);
                             att.Add(reader.Name.ToString(), reader.Value.ToString());
                         }
                     }
                     startElement(namespaceURI, name, name, att);
                     break;
                 case XmlNodeType.EndElement:
                     endElement(reader.NamespaceURI,
                            reader.Name, reader.Name);
                     break;
                 case XmlNodeType.Text:
                     //Debug.Log("TEXT: " + reader.Value);
                     characters(reader.Value.ToCharArray(), 0, reader.Value.Length);
                     break;
                     // There are many other types of nodes, but
                     // we are not interested in them
             }
         }
     }
     catch (XmlException e)
     {
         Console.WriteLine(e.Message);
     }
 }
开发者ID:Synpheros,项目名称:eAdventure4Unity,代码行数:43,代码来源:XMLHandler.cs

示例5: AddCurrency

    /// <summary>
    /// Reads through the XML file and adds the new
    /// exchange rates to the list.
    /// </summary>
    private static void AddCurrency(Dictionary<string, double> currencies, XmlTextReader xmlReader)
    {
        if (xmlReader.Name == "Cube")
        {
          if (xmlReader.AttributeCount == 1)
          {
        xmlReader.MoveToAttribute("time");
        _LastUpdated = DateTime.Parse(xmlReader.Value);
          }

          if (xmlReader.AttributeCount == 2)
          {
        xmlReader.MoveToAttribute("currency");
        string name = xmlReader.Value;

        xmlReader.MoveToAttribute("rate");
        //double rate = double.Parse(xmlReader.Value.Replace(".", ","));
        double rate = double.Parse(xmlReader.Value);

        currencies.Add(name, rate);
          }
        }
    }
开发者ID:shoopi,项目名称:essexbooking,代码行数:27,代码来源:Currency.cs

示例6: LoadXmlFileInTreeView

        public void LoadXmlFileInTreeView(TreeView treeView, string fileName)
        {
            XmlTextReader reader = null;
            try
            {
                treeView.BeginUpdate();
                reader = new XmlTextReader(fileName);

                TreeNode n = new TreeNode(fileName);
                treeView.Nodes.Add(n);
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        bool isEmptyElement = reader.IsEmptyElement;
                        StringBuilder text = new StringBuilder();
                        text.Append(reader.Name);
                        int attributeCount = reader.AttributeCount;
                        if (attributeCount > 0)
                        {
                            text.Append(" ( ");
                            for (int i = 0; i < attributeCount; i++)
                            {
                                if (i != 0) text.Append(", ");
                                reader.MoveToAttribute(i);
                                text.Append(reader.Name);
                                text.Append(" = ");
                                text.Append(reader.Value);
                            }
                            text.Append(" ) ");
                        }

                        if (isEmptyElement)
                        {
                            n.Nodes.Add(text.ToString());
                        }
                        else
                        {
                            n = n.Nodes.Add(text.ToString());
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        n = n.Parent;
                    }
                    else if (reader.NodeType == XmlNodeType.XmlDeclaration)
                    {

                    }
                    else if (reader.NodeType == XmlNodeType.None)
                    {
                        return;
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        n.Nodes.Add(reader.Value);
                    }
                }
            }
            finally
            {
                treeView.EndUpdate();
                reader.Close();
            }
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:65,代码来源:GeneralClasses.cs

示例7: DeserializeTreeView

        public void DeserializeTreeView(TreeView treeView, string fileName)
        {
            XmlTextReader reader = null;
            try
            {
                // disabling re-drawing of treeview till all nodes are added
                treeView.BeginUpdate();
                reader = new XmlTextReader(fileName);

                TreeNode parentNode = null;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == XmlNodeTag)
                        {
                            TreeNode newNode = new TreeNode();
                            bool isEmptyElement = reader.IsEmptyElement;

                            // loading node attributes
                            int attributeCount = reader.AttributeCount;
                            if (attributeCount > 0)
                            {
                                for (int i = 0; i < attributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);
                                    SetAttributeValue(newNode, reader.Name, reader.Value);
                                }
                            }

                            // add new node to Parent Node or TreeView
                            if (parentNode != null)
                                parentNode.Nodes.Add(newNode);
                            else
                                treeView.Nodes.Add(newNode);

                            // making current node 'ParentNode' if its not empty
                            if (!isEmptyElement)
                            {
                                parentNode = newNode;
                            }
                        }
                    }
                    // moving up to in TreeView if end tag is encountered
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (reader.Name == XmlNodeTag)
                        {
                            parentNode = parentNode.Parent;
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.XmlDeclaration)
                    { //Ignore Xml Declaration
                    }
                    else if (reader.NodeType == XmlNodeType.None)
                    {
                        return;
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        parentNode.Nodes.Add(reader.Value);
                    }
                }
            }
            finally
            {
                // enabling redrawing of treeview after all nodes are added
                treeView.EndUpdate();
                reader.Close();
            }
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:72,代码来源:GeneralClasses.cs

示例8: transform

    private static void transform(XmlTextReader xin, XmlTextWriter xout,
        Dictionary<string,string> guids)
    {
        try {
          while (xin.Read()) {
        if (xin.NodeType == XmlNodeType.Element) {
          string name = xin.Name;
          bool empty = xin.IsEmptyElement;
          //Extract attributes
          KeyValuePair<string,string>[] attr =
            new KeyValuePair<string,string>[xin.HasAttributes?
                                            xin.AttributeCount : 0];
          for (int i = 0; i < attr.Length; ++i) {
            xin.MoveToAttribute(i);
            attr[i] = new KeyValuePair<string,string>(xin.Name, xin.Value);
          }

          //Perform GUID translation
          translateGUIDs(attr, guids, xin);

          //Write new node(s)
          if (name == "autowixfilecomponents")
            writeFileComponents(xout, name, attr, empty, guids, xin);
          else if (name == "autowixcomponentrefs")
            writeComponentRefs(xout, empty, xin);
          else
            writeVerbatim(xout, name, attr, empty);
        } else if (xin.NodeType == XmlNodeType.EndElement) {
          xout.WriteEndElement();
        }
          }
        } catch (XmlException e) {
          Console.WriteLine("Error reading input: " + e.Message);
          Environment.Exit(5);
        }
    }
开发者ID:AltSysrq,项目名称:AutoWiX,代码行数:36,代码来源:autowix.cs

示例9: ParseMath

        public void ParseMath(XmlTextReader reader)
        {
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                String elementName = reader.LocalName.ToLower();

                Hashtable attributes = new Hashtable();
                if (reader.HasAttributes)
                {
                    for (int i = 0; i < reader.AttributeCount; i++)
                    {
                        reader.MoveToAttribute(i);
                        attributes.Add(reader.Name.ToLower(), reader.Value);
                    }
                }
                if (elementName == "csymbol")
                {
                    reader.Skip(); // csymbol will have an unimportant text childNode
                }

                StartMathElement(elementName, attributes);
                break;

            case XmlNodeType.EndElement:
                EndMathElement(reader.Name.ToLower());
                break;

            case XmlNodeType.Text: // from cn or ci
                MathCharacters(reader.Value);
                break;

            }
        }
开发者ID:dorchard,项目名称:mucell,代码行数:34,代码来源:Reader.cs

示例10: Parse

        public void Parse(string filePath)
        {
            try
            {
            XmlTextReader reader = new XmlTextReader(filePath);
            reader.WhitespaceHandling = WhitespaceHandling.None;
            while (reader.Read())
            {
                if (this.inMathNode == true)
                {
                    ParseMath(reader);
                    continue;
                }

                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (reader.Prefix != String.Empty)
                        {
                            // namespaced element not part of SBML
                            reader.Skip();
                        }
                        String elementName = reader.LocalName.ToLower();

                        if (elementName == "notes" ||
                            elementName == "annotation")
                        {
                            // not part of the SBML model
                            //reader.Skip(); // need to skip then move back one node
                            reader.Read();
                        }

                        Hashtable attributes = new Hashtable();
                        if (reader.HasAttributes)
                        {
                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                if (reader.Name == "xmlns" && elementName != "math"
                                    && elementName != "sbml")
                                {
                                    // namespaced node/subtree not part of SBML...unless MathML
                                    reader.MoveToElement();
                                    reader.Skip();
                                }
                                if (reader.Name == "specie")
                                {
                                    // horrible leftover from SBML Level 1
                                    attributes.Add("species", reader.Value);
                                }
                                else
                                {
                                    attributes.Add(reader.Name.ToLower(), reader.Value);
                                }
                            }
                        }
                        StartElement(elementName, attributes);
                        break;

                    case XmlNodeType.EndElement:
                        EndElement(reader.LocalName.ToLower());
                        break;
                    // There are many other types of nodes, but
                    // we are not interested in them
                }
            }
            }
            catch (XmlException e)
            {
            Console.WriteLine(e.Message);
            }
        }
开发者ID:dorchard,项目名称:mucell,代码行数:72,代码来源:Reader.cs

示例11: SetPropertyObject

	private void SetPropertyObject(object objParent, PropertyInfo pi, XmlTextReader tr, NodeStyle ns)
	{
		object obj;

		switch (pi.PropertyType.FullName)
			{
				case "System.Drawing.Font" :
					structFont fnt;
					fnt.Style = 0;
					fnt.Unit = GraphicsUnit.Point;
					fnt.Name="";
					fnt.Size=0;
					fnt.gdiCharSet=0;
					fnt.gdiVerticalFont=false;

					for (int i = 0; i < tr.AttributeCount; i++)
					{
						tr.MoveToAttribute(i);

						switch (tr.Name.ToUpper())
						{
							case "NAME" : fnt.Name = tr.Value; break;
							case "SIZE" : fnt.Size = Convert.ToSingle(tr.Value); break;
							case "GDICHARSET" : fnt.gdiCharSet = Convert.ToByte(tr.Value); break;
							case "GDIVERTICALFONT" : fnt.gdiVerticalFont = Convert.ToBoolean(tr.Value); break;
							case "BOLD" : if (Convert.ToBoolean(tr.Value)) fnt.Style = fnt.Style | FontStyle.Bold ; break;
							case "ITALIC" : if (Convert.ToBoolean(tr.Value)) fnt.Style = fnt.Style | FontStyle.Italic ; break;
							case "STRIKEOUT" : if (Convert.ToBoolean(tr.Value)) fnt.Style = fnt.Style | FontStyle.Strikeout ; break;
							case "UNDERLINE" : if (Convert.ToBoolean(tr.Value)) fnt.Style = fnt.Style | FontStyle.Underline; break;
							case "UNIT" : 
								Type o = oTV.Style.NodeStyle.Font.Unit.GetType();
								fnt.Unit = (System.Drawing.GraphicsUnit)System.Enum.Parse(o , tr.Value, true);
								break;

							default :
								break;
						}
					}

					System.Drawing.Font NewFont = new System.Drawing.Font(fnt.Name, fnt.Size, fnt.Style, fnt.Unit, fnt.gdiCharSet, fnt.gdiVerticalFont);

				Type t1 = objParent.GetType();

				switch (t1.FullName)
				{
					case "PureComponents.TreeView.NodeStyle" :						
						ns.Font = NewFont;
						break;

					case "PureComponents.TreeView.NodeTooltipStyle" :
						ns.TooltipStyle.Font = NewFont;
						break;

				}

					break;

				default :
					

					obj = (System.Type.GetType(pi.GetType().Name));
					obj = pi.GetValue(objParent,null);

					for (int i = 0; i < tr.AttributeCount; i++)
					{

						tr.MoveToAttribute(i);

						SetProperty(obj, tr.Name, tr.Value);

					}
					break;
			}

	}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:75,代码来源:TreeViewXML.cs

示例12: LoadNode

	private Node LoadNode(string sXML)
	{
		Node ReturnedNode = null;

		if (sXML.Length == 0) return ReturnedNode;

		ReturnedNode = new Node();
		ReturnedNode.TreeView = oTV;

		XmlTextReader tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);		

		while (tr.Read())
			if (tr.IsStartElement()) break;

		//nastavi atributy nodu
		for (int i = 0; i < tr.AttributeCount; i++)
		{

			tr.MoveToAttribute(i);

			SetProperty(ReturnedNode, tr.Name, tr.Value);

		}

		bool NextElement = true;


		while (NextElement)
		{
			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			switch (ElementName.ToUpper())
			{
				case "TEXT" :
					string s = this.LoadMultiLineText(tr.ReadString());
					
					SetProperty(ReturnedNode, "Text", s);

					break;

				case "FLAG" :
					for (int i = 0; i < tr.AttributeCount; i++)
					{
						tr.MoveToAttribute(i);

						SetProperty(ReturnedNode.Flag, tr.Name, tr.Value);
					}
					break;

				case "NODESTYLE" :
					this.LoadObject(ReturnedNode, tr.ReadOuterXml(), ReturnedNode.NodeStyle);
					break;

				case "NODE" :				
					Node n = LoadNode(tr.ReadOuterXml());					
					if (n != null)
					{
						ReturnedNode.Nodes.Add(n);
						//n.Parent = ReturnedNode;
						//n.TreeView = ReturnedNode.TreeView;
					}
					break;

			}
		}

		return ReturnedNode;
	}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:73,代码来源:TreeViewXML.cs

示例13: LoadNodes

	private void LoadNodes(object objParent, string sXML)
	{
		if (sXML.Length == 0) return;

		XmlTextReader tr = new XmlTextReader(sXML, System.Xml.XmlNodeType.Element , null);

		while (tr.ReadState != ReadState.EndOfFile)
		{

			while (tr.Read())
				if (tr.IsStartElement()) break;

			string ElementName = tr.LocalName;

			if (ElementName.Length == 0) break;

			switch (ElementName.ToUpper())
			{
				case "BEHAVIOR" :

					for (int i = 0; i < tr.AttributeCount; i++)
					{						

						tr.MoveToAttribute(i);						

						SetProperty(oTV, tr.Name, tr.Value);

					}
					
					break;

				case "NODE" :

					while (tr.ReadState != ReadState.EndOfFile)
					{
						if (tr.LocalName.ToUpper() == "NODE")
						{
							Node n = null;

							string s = tr.ReadOuterXml();

							if (s.Length > 0)
							{
								n = LoadNode(s);
					
								if (n != null) oTV.Nodes.Add(n);
							}
						}
						else tr.Read();
					}

					break;
			}

		}
	}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:56,代码来源:TreeViewXML.cs


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