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


C# XmlTextReader.MoveToAttribute方法代码示例

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


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

示例1: ReadFromFile

        private ArrayList ReadFromFile(string file)
        {
            ArrayList list = new ArrayList();
            XmlReader reader = new XmlTextReader(file);

            while (reader.Read())
            {
                if (reader.NodeType != XmlNodeType.Element)
                    continue;
                
                if(string.Compare(reader.Name, @"data") != 0)
                    continue;

                if (!reader.HasAttributes)
                    continue;

                if(!reader.MoveToAttribute(@"xml:space"))
                    continue;

                if (string.Compare(reader.Value, @"preserve") != 0)
                    continue;

                if (!reader.MoveToAttribute("name"))
                    continue;
                
                list.Add(reader.Value);
            }

            reader.Close();
            return list;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:31,代码来源:ResourceFileComparer.cs

示例2: MakeList

        public List<Article> MakeList(params string[] searchCriteria)
        {
            List<Article> articles = new List<Article>();

            using (
                XmlTextReader reader =
                    new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles") + "&count=" + Count))))
            {
                while (reader.Read())
                {
                    if (reader.Name.Equals("site"))
                    {
                        reader.MoveToAttribute("address");
                        string site = reader.Value;

                        if (site != Common.GetSite())
                            //Probably shouldnt get this as the wanted site was sent to the server
                        {
                            MessageBox.Show("Wrong Site");
                        }
                    }
                    else if (reader.Name.Equals("article"))
                    {
                        reader.MoveToAttribute("id");
                        int id = int.Parse(reader.Value);
                        string title = reader.ReadString();
                        articles.Add(new Article(title));
                        if (!TypoScanBasePlugin.PageList.ContainsKey(title))
                            TypoScanBasePlugin.PageList.Add(title, id);
                    }
                }
            }
            TypoScanBasePlugin.CheckoutTime = DateTime.Now;
            return articles;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:35,代码来源:TypoScanListMakerPlugin.cs

示例3: Parse

		private void Parse( XmlTextReader xml )
		{
			if ( xml.MoveToAttribute( "name" ) )
			{
				m_Name = xml.Value;
			}
			else
			{
				m_Name = "empty";
			}

			int x = 0, y = 0, z = 0;

			if ( xml.MoveToAttribute( "x" ) )
			{
				x = Utility.ToInt32( xml.Value );
			}

			if ( xml.MoveToAttribute( "y" ) )
			{
				y = Utility.ToInt32( xml.Value );
			}

			if ( xml.MoveToAttribute( "z" ) )
			{
				z = Utility.ToInt32( xml.Value );
			}

			m_Location = new Point3D( x, y, z );
		}
开发者ID:xrunuo,项目名称:xrunuo,代码行数:30,代码来源:ChildNode.cs

示例4: stworz_liste_plikow_xml

        public string[] stworz_liste_plikow_xml()
        {
            //tworzenie listy plików z folderu do porównywarki.

                string[] files = Directory.GetFiles(".", "top100_*.xml");
                int i = 0;
                string data = "", czas = "";

                if (files.Length != 0)
                {
                    foreach (string file in files)
                    {
                        XmlTextReader xtr = new XmlTextReader(file);
                        xtr.Read();
                        xtr.Read();
                        xtr.Read();
                        xtr.MoveToAttribute("data");
                        data = xtr.Value;
                        xtr.MoveToAttribute("godzina");
                        czas = xtr.Value;
                        plikiHistoriaKlasa[i] = file.ToString().Substring(2);

                        i++;
                       }

                }
                return plikiHistoriaKlasa;
        }
开发者ID:przemekwa,项目名称:BGGTop100,代码行数:28,代码来源:obsluga_xml.cs

示例5: Load

		public void Load (string file, bool system)
		{
			XmlTextReader reader = new XmlTextReader (file);
			string set_name = null;
			List<string> counters = new List<string> ();

			while (reader.Read ()) {
				if (reader.NodeType == XmlNodeType.Element) {
					string name = reader.Name;
					if (name == "mperfmon")
						continue;
					if (name == "update") {
						for (int i = 0; i < reader.AttributeCount; ++i) {
							reader.MoveToAttribute (i);
							if (reader.Name == "interval") {
								timeout = uint.Parse (reader.Value);
							}
						}
						continue;
					}
					if (name == "set") {
						for (int i = 0; i < reader.AttributeCount; ++i) {
							reader.MoveToAttribute (i);
							if (reader.Name == "name") {
								set_name = reader.Value;
							}
						}
						continue;
					}
					if (name == "counter") {
						string cat = null, counter = null;
						for (int i = 0; i < reader.AttributeCount; ++i) {
							reader.MoveToAttribute (i);
							if (reader.Name == "cat") {
								cat = reader.Value;
							} else if (reader.Name == "name") {
								counter = reader.Value;
							}
						}
						if (cat != null && counter != null) {
							counters.Add (cat);
							counters.Add (counter);
						}
						continue;
					}
				} else if (reader.NodeType == XmlNodeType.EndElement) {
					if (reader.Name == "set") {
						sets.Add (new CounterSet (set_name, counters, system));
						set_name = null;
						counters.Clear ();
					}
				}
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:54,代码来源:Config.cs

示例6: Currency

 public Currency()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     try
     {
         xml = new XmlTextReader(sourceUrl); //tries to download XML file and create the Reader object
     }
     catch (WebException we) // if download is imposible, creates defalt value for BGN and EUR and throws an exception
     {
         this.baseCurrency = "EUR";
         this.exchangeRates.Add(this.baseCurrency, 1M);
         this.exchangeRates.Add("BGN", 1.9558M);
         this.date = DateTime.Now;
         throw new WebException("Error downloading XML, exchange rate created for BGN only, base currency EUR!", we);
     }
     try
     {
         while (xml.Read())
         {
             if (xml.Name == "Cube")
             {
                 if (xml.AttributeCount == 1)
                 {
                     xml.MoveToAttribute("time");
                     this.date = DateTime.Parse(xml.Value); // gets the date on which this rates are valid
                 }
                 if (xml.AttributeCount == 2)
                 {
                     xml.MoveToAttribute("currency");
                     this.currency = xml.Value;
                     xml.MoveToAttribute("rate");
                     try
                     {
                         this.rate = decimal.Parse(xml.Value);
                     }
                     catch (FormatException fe)
                     {
                         throw new FormatException("Urecognised format!", fe);
                     }
                     this.exchangeRates.Add(currency, rate); //ads currency and rate to exchange rate table
                 }
                 xml.MoveToNextAttribute();
             }
         }
     }
     catch (XmlException xe)
     {
         throw new XmlException("Unable to parse Euro foreign exchange reference rates XML!", xe);
     }
     this.baseCurrency = "EUR"; // if XML parsed, add base currency
     this.exchangeRates.Add(this.baseCurrency, 1M);
 }
开发者ID:stamo,项目名称:Currency-Exchange-Class-CSharp,代码行数:52,代码来源:Currency.cs

示例7: CAGObject

		public CAGObject( CAGCategory parent, XmlTextReader xml )
		{
			m_Parent = parent;

			if ( xml.MoveToAttribute( "type" ) )
				m_Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );

			if ( xml.MoveToAttribute( "gfx" ) )
				m_ItemID = XmlConvert.ToInt32( xml.Value );

			if ( xml.MoveToAttribute( "hue" ) )
				m_Hue = XmlConvert.ToInt32( xml.Value );
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:13,代码来源:CategorizedAddGump.cs

示例8: CreateLookup

        public void CreateLookup(SPFeatureReceiverProperties properties, SPWeb web, String filePath)
        {
            string fieldId;
            bool isReading = true;
            XmlDocument document = GetXmlDocument(properties.Definition, filePath, web.Locale);

            using (XmlTextReader reader = new XmlTextReader(new StringReader(document.OuterXml)))
            {
                CreateListMapping(properties);
                while (true)
                {
                    if (reader.LocalName != "Field" || isReading)
                    {
                        if (!reader.Read())
                        {
                            break;
                        }
                    }
                    if (reader.LocalName == "Field")
                    {
                        if (reader.MoveToAttribute("Type") &&
                            reader.Value == "Lookup" &&
                            reader.MoveToAttribute("Name"))
                        {
                            fieldId = reader.Value;
                            if (lookupsListMapping.ContainsKey(fieldId))
                            {
                                String listName = lookupsListMapping[fieldId];
                                SPList list = GetListForLookup(listName, web);
                                reader.MoveToContent();
                                XmlDocument doc = new XmlDocument();
                                String fieldElement = reader.ReadOuterXml();
                                doc.LoadXml(fieldElement);
                                XPathNavigator navigator = doc.DocumentElement.CreateNavigator();
                                navigator.CreateAttribute("", "List", "", list.ID.ToString());

                                SPFieldLookup field = (SPFieldLookup)web.Fields[fieldId];

                                AddWebIdAttribute(web, doc);
                                field.SchemaXml = RemoveXmlnsAttribute(doc.OuterXml);

                                field.Update(true);
                                isReading = false;
                                continue;
                            }
                        }
                    }
                    isReading = true;
                }
            }
        }
开发者ID:oivoodoo,项目名称:voo-university,代码行数:51,代码来源:LookupReciever.cs

示例9: LoadConfiguration

        public void LoadConfiguration(String configFilePath)
        {
            // Load the config file
            XmlTextReader xmlReader = null;

            try
            {
                xmlReader = new XmlTextReader(configFilePath);

                // Read all the infos
                while (xmlReader.Read())
                {
                    xmlReader.MoveToContent();
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlReader.Name)
                        {
                            case "TorrentSrcDirectory":
                                xmlReader.MoveToAttribute("path");
                                m_torrentSrcDirector = xmlReader.Value;
                                break;
                            case "TVShowDirectory":
                                xmlReader.MoveToAttribute("path");
                                m_tvShowDirectory = xmlReader.Value;
                                break;
                            case "FileExtensions":
                                xmlReader.MoveToAttribute("value");
                                m_fileExtensions = xmlReader.Value;
                                break;
                            case "TVShow":
                                TVShow tvShow = new TVShow();
                                ReadTVShowInfos(xmlReader, tvShow);
                                m_tvShows.Add(tvShow);
                                break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Program.LogMessageToFile(String.Format("Unable to process configuration file, {0}", e.ToString()));
            }
            finally
            {
                if (xmlReader != null)
                    xmlReader.Close();
            }
        }
开发者ID:BimBamBoum,项目名称:TVShowClassifier,代码行数:48,代码来源:Configuration.cs

示例10: Parse

		private void Parse( XmlTextReader xml )
		{
			if ( xml.MoveToAttribute( "name" ) )
				m_Name = xml.Value;
			else
				m_Name = "empty";

			if ( xml.IsEmptyElement )
			{
				m_Children = new object[0];
			}
			else
			{
				ArrayList children = new ArrayList();

				while ( xml.Read() && xml.NodeType == XmlNodeType.Element )
				{
					if ( xml.Name == "child" )
					{
						ChildNode n = new ChildNode( xml, this );

						children.Add( n );
					}
					else
					{
						children.Add( new ParentNode( xml, this ) );
					}
				}

				m_Children = children.ToArray();
			}
		}
开发者ID:Godkong,项目名称:Origins,代码行数:32,代码来源:ParentNode.cs

示例11: ReadXMLFile

 public void ReadXMLFile()
 {
     XmlTextReader xmlReader = null;
     try
     {
         string strPath = "C:\\temp\\kai\\Rules\\Russian_1.xml";
         xmlReader = new XmlTextReader (strPath);
         while (xmlReader.Read())
         {
             if (XmlNodeType.Element == xmlReader.NodeType)
             {
                 sCurrentElement = xmlReader.Name;
                 int nAttr = xmlReader.AttributeCount;
                 for (int iAttr = 0; iAttr < nAttr; ++iAttr)
                 {
                     xmlReader.MoveToAttribute (iAttr);
                     string sAttr = xmlReader.Name;
     //                                int ggg = 0;
                 }
             }   // if
         }   //  while...
     }   // try
     catch
     {
         int ggg = 0;
     }
     finally
     {
         xmlReader.Close();
     }
 }
开发者ID:kbogatyrev,项目名称:Kai,代码行数:31,代码来源:Transcriber.cs

示例12: MakeList

        public List<Article> MakeList(params string[] searchCriteria)
        {
            List<Article> articles = new List<Article>();

            // TODO: must support other wikis
            if (Variables.Project != ProjectEnum.wikipedia || Variables.LangCode != LangCodeEnum.en)
            {
                MessageBox.Show("This plugin currently supports only English Wikipedia",
                    "TypoScan", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return articles;
            }

            for (int i = 0; i < Iterations; i++)
            {
                using (
                    XmlTextReader reader =
                        new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles")))))
                {
                    while (reader.Read())
                    {
                        if (reader.Name.Equals("article"))
                        {
                            reader.MoveToAttribute("id");
                            int id = int.Parse(reader.Value);
                            string title = reader.ReadString();
                            articles.Add(new Article(title));
                            if (!TypoScanAWBPlugin.PageList.ContainsKey(title))
                                TypoScanAWBPlugin.PageList.Add(title, id);
                        }
                    }
                }
            }
            TypoScanAWBPlugin.CheckoutTime = DateTime.Now;
            return articles;
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:35,代码来源:TypoScanListMakerPlugin.cs

示例13: LoadLogs

        public bool LoadLogs(String[] uris)
        {
            try
            {
                foreach (String uri in uris)
                {
                    XML = new XmlTextReader(uri);

                    while (XML.Read())
                    {
                        Console.Write("loading log");
                        if (XML.Name == "PointingMagnifier")
                        {
                            p.ReadLog(XML);
                        }

                        if (XML.HasAttributes)
                        {
                            for (int i = 0; i < XML.AttributeCount; i++)
                            {
                                XML.MoveToAttribute(i);
                            }
                        }
                    }
                }
            }
            catch
            {
                return false;
            }
            lblNumStates.Text = String.Format("States: {0}", p.NumStates());
            lblNumEvents.Text = String.Format("Events: Active - {0}, Inactive - {1}", p.NumActiveEvents(), p.NumNonActiveEvents());
            return true;
        }
开发者ID:ajansen7,项目名称:Pointing-Magnifier,代码行数:34,代码来源:LoadLog.cs

示例14: CAGCategory

		public CAGCategory( CAGCategory parent, XmlTextReader xml )
		{
			m_Parent = parent;

			if ( xml.MoveToAttribute( "title" ) )
				m_Title = xml.Value;
			else
				m_Title = "empty";

			if ( m_Title == "Docked" )
				m_Title = "Docked 2";

			if ( xml.IsEmptyElement )
			{
				m_Nodes = new CAGNode[0];
			}
			else
			{
				ArrayList nodes = new ArrayList();

				/*while ( xml.Read() && xml.NodeType != XmlNodeType.EndElement )
				{
					if ( xml.NodeType == XmlNodeType.Element && xml.Name == "object" )
						nodes.Add( new CAGObject( this, xml ) );
					else if ( xml.NodeType == XmlNodeType.Element && xml.Name == "category" )
						nodes.Add( new CAGCategory( this, xml ) );
					else
						xml.Skip();
				}*/

				m_Nodes = (CAGNode[])nodes.ToArray( typeof( CAGNode ) );
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:33,代码来源:CategorizedAddGump.cs

示例15: readCurrentElement

        /// <summary>
        ///   Parser recursiv de elemente XML.
        /// </summary>
        /// <param name="reader">Cititorul secvenţial care a deschis fişierul XML</param>
        /// <returns>Elementul XML parsat care conţine toate atributele şi subelementele sale</returns>
        private static XMLElement readCurrentElement(XmlTextReader reader)
        {
            if (!reader.IsStartElement()) {

                return null;
            }

            bool hasChildren = !reader.IsEmptyElement;

            XMLElement result = new XMLElement();

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

                reader.MoveToAttribute(i);
                result.addAttribute(reader.Name, reader.Value);
            }

            if (hasChildren) {

                while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) {

                    if (reader.IsStartElement()) {

                        result.addElement(reader.Name, readCurrentElement(reader));
                    }
                }
            }

            reader.Read();

            return result;
        }
开发者ID:slung,项目名称:fuzzyselector,代码行数:37,代码来源:XMLParser.cs


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