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


C# XmlNodeList.Item方法代码示例

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


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

示例1: GetSuccessfulTestSuites

      public static List<XmlNode> GetSuccessfulTestSuites(XmlNodeList xmlNodeList)
      {
         List<XmlNode> resultList = new List<XmlNode>();

         for (int i = 0; i < xmlNodeList.Count; ++i)
         {
            XmlNode nameNode =
               xmlNodeList.Item(i).Attributes.GetNamedItem("name");

            XmlNode successNode =
               xmlNodeList.Item(i).Attributes.GetNamedItem("success");

            XmlNode executedNode =
              xmlNodeList.Item(i).Attributes.GetNamedItem("executed");

            if (successNode == null) continue;

            if (executedNode == null) continue;

            try
            {
               if (successNode.Value.Equals("True"))
                  resultList.Add(xmlNodeList.Item(i));
            }
            catch (Exception ex)
            {
               //ignore...
               Logger.LogException(ex);
            }
         }

         return resultList;
      }
开发者ID:codemonkies,项目名称:UTGV1.0,代码行数:33,代码来源:NUnitXmlResultProccessor.cs

示例2: Load

        public static GuidanceShift Load(XmlNodeList inputNode, TaskDataDocument taskDataDocument)
        {
            var loader = new GuidanceShiftLoader(taskDataDocument);

            var node = inputNode.Item(0);
            return loader.Load(node);
        }
开发者ID:ADAPT,项目名称:ISOv4Plugin,代码行数:7,代码来源:GuidanceShiftLoader.cs

示例3: ProcessWaypoints

        private static void ProcessWaypoints(XmlNodeList waypoints, IWriter p_writer)
        {
            if (waypoints.Count != 0)
            {
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(waypoints.Item(0).OwnerDocument.NameTable);
                nsmgr.AddNamespace(ms_defaultNamespace, waypoints.Item(0).OwnerDocument.DocumentElement.NamespaceURI);

                foreach (XmlNode mark in waypoints)
                {
                    decimal lat = Decimal.Parse(mark.Attributes.GetNamedItem(ms_gpx_lat).Value, Utils.ms_formatProviderEn);
                    decimal lng = Decimal.Parse(mark.Attributes.GetNamedItem(ms_gpx_lon).Value, Utils.ms_formatProviderEn);
                    String name = mark.SelectSingleNode(GetFullName(ms_gpx_name), nsmgr).InnerText;

                    XmlNode elevationtNode = mark.SelectSingleNode(GetFullName(ms_gpx_ele), nsmgr);
                    int elevation = elevationtNode != null ? Decimal.ToInt32(Decimal.Parse(elevationtNode.InnerText, Utils.ms_formatProviderEn)) : 0;

                    XmlNode linkNode = mark.SelectSingleNode(GetFullName("link"), nsmgr);
                    String link = linkNode != null ? linkNode.Attributes.GetNamedItem("href").Value : String.Empty;

                    p_writer.AddWayPoint(name, lat, lng, elevation, link);
                }
            }
        }
开发者ID:AlexeySoev,项目名称:party1996,代码行数:23,代码来源:GPX.cs

示例4: getRssItem

        // Set un épisode d'un podcast
        private string getRssItem(XmlNodeList rssItems, int iCurrentNode, string rssItemAttribute)
        {
            string returnedValue = "";

            XmlNode rssNode = rssItems.Item(iCurrentNode).SelectSingleNode(rssItemAttribute);
            if (rssNode != null)
            {
                returnedValue = rssNode.InnerText;
            }
            else
            {
                returnedValue = "";
            }

            return returnedValue;
        }
开发者ID:crousti42,项目名称:crousticast,代码行数:17,代码来源:RssFlow.cs

示例5: Browser_Load

 private void Browser_Load(object sender, EventArgs e)
 {
     try
     {
         d = new XmlDocument();
         d.Load(filename);
         fav = d.SelectNodes("favorite/site");
         XmlNode site;
         for (int i = 0; i < fav.Count; i++)
         {
             site = fav.Item(i).SelectSingleNode("titlu");
             favcombobox.Items.Add(site.InnerText);
         }
     }
     catch
     {
         ok = false;
     }
     if (ok == false)
     {
         XmlTextWriter writer = new XmlTextWriter("favorite.xml", Encoding.Unicode);
         writer.Formatting = Formatting.Indented;
         writer.WriteStartElement("favorite");
         writer.WriteStartElement("site");
         writer.WriteStartElement("titlu");
         writer.WriteString("Google");
         writer.WriteEndElement();
         writer.WriteStartElement("url");
         writer.WriteString("http://www.google.com/");
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.Flush();
         writer.Close();
         ok = true;
     }
 }
开发者ID:scipv,项目名称:CSharp-Repo,代码行数:37,代码来源:browser.cs

示例6: AddNodes

        public bool AddNodes(XmlNodeList oSourceList, String sName, String sParent)
        {
            try
            {
                if (oSourceList != null)
                {
                    // call AddNode for each item in the source node list
                    // return true only if all nodes are added successfully

                    int i = 0;
                    while (i < oSourceList.Count)
                    {
                        if (!AddNode(oSourceList.Item(i), sName, sParent)) return false;
                        i++;
                    }
                    return true;
                }
            }
            catch (Exception)
            {
                // error handling code
            }
            return false;
        }
开发者ID:OleksandrKulchytskyi,项目名称:VkManager,代码行数:24,代码来源:XmlDocumentExt.cs

示例7: UpdatePowerUps

        private void UpdatePowerUps(XmlDocument doc, XmlNodeList levelData)
        {
            //Delete powerUp
            foreach (string[] deletedPowerUp in editor.deletedPowerUps)
            {
                foreach (XmlNode powerUp in levelData.Item(1))
                {
                    if (powerUp.Name.CompareTo("tile") == 0)
                    {
                        XmlAttribute attributeType = powerUp.Attributes["type"];
                        XmlAttribute attributePosX = powerUp.Attributes["posX"];
                        XmlAttribute attributePosZ = powerUp.Attributes["posZ"];
                        if (attributeType.Value.CompareTo(deletedPowerUp[0]) == 0 && attributePosX.Value.CompareTo(deletedPowerUp[1]) == 0 && attributePosZ.Value.CompareTo(deletedPowerUp[2]) == 0)
                        {
                            levelData.Item(1).RemoveChild(powerUp);
                        }
                    }
                }
            }

            //Add powerUp
            foreach (string[] newPowerUp in editor.newPowerUps)
            {
                XmlNode nuevo = doc.CreateNode(XmlNodeType.Element, "tile", "");
                ((XmlElement)nuevo).SetAttribute("type", newPowerUp[0]);
                ((XmlElement)nuevo).SetAttribute("posX", newPowerUp[1]);
                ((XmlElement)nuevo).SetAttribute("posZ", newPowerUp[2]);
                levelData.Item(1).AppendChild(nuevo);
            }
        }
开发者ID:nadita,项目名称:vj,代码行数:30,代码来源:XmlMngr.cs

示例8: UpdateEnemies

        private void UpdateEnemies(XmlDocument doc, XmlNodeList levelData)
        {
            //Delete enemies
            foreach (string[] deletedEnemy in editor.deletedEnemies)
            {
                foreach (XmlNode enemy in levelData.Item(3))
                {
                    if (enemy.Name.CompareTo("tile") == 0)
                    {
                        XmlAttribute attributeType = enemy.Attributes["type"];
                        XmlAttribute attributePosX = enemy.Attributes["posX"];
                        XmlAttribute attributePosZ = enemy.Attributes["posZ"];
                        if (attributeType.Value.CompareTo(deletedEnemy[0]) == 0 && attributePosX.Value.CompareTo(deletedEnemy[1]) == 0 && attributePosZ.Value.CompareTo(deletedEnemy[2]) == 0)
                        {
                            levelData.Item(2).RemoveChild(enemy);
                        }
                    }
                }
            }

            //Add enemies
            foreach (string[] newEnemy in editor.newEnemies)
            {
                XmlNode nuevo = doc.CreateNode(XmlNodeType.Element, "tile", "");
                ((XmlElement)nuevo).SetAttribute("type", newEnemy[0]);
                ((XmlElement)nuevo).SetAttribute("posX", newEnemy[1]);
                ((XmlElement)nuevo).SetAttribute("posZ", newEnemy[2]);
                levelData.Item(2).AppendChild(nuevo);
            }
        }
开发者ID:nadita,项目名称:vj,代码行数:30,代码来源:XmlMngr.cs

示例9: LerRSS

        public void LerRSS(string URL)
        {
            try
            {
                objBD = new bd();

                RSS = WebRequest.Create(URL);
                RSS_Retorno = RSS.GetResponse();

                RSS_Stream = RSS_Retorno.GetResponseStream();
                XML = new XmlDocument();
                XML.Load(RSS_Stream);

                XML_Itens = XML.SelectNodes("rss/channel/item");

                TituloRSS = "";
                LinkRSS = "";
                DataRSS = "";

                TotalItens = XML_Itens.Count;
                if (TotalItens > 10)
                {
                    TotalItens = 10;
                }
                for (i = 0; i < TotalItens; i++)
                {
                    rsResultado = XML_Itens.Item(i).SelectSingleNode("title");
                    if (rsResultado != null)
                    {
                        TituloRSS = rsResultado.InnerText;
                    }
                    else
                    {
                        TituloRSS = "";
                    }
                    rsResultado = XML_Itens.Item(i).SelectSingleNode("link");
                    if (rsResultado != null)
                    {
                        LinkRSS = rsResultado.InnerText;
                    }
                    else
                    {
                        LinkRSS = "";
                    }
                    rsResultado = XML_Itens.Item(i).SelectSingleNode("pubDate");
                    if (rsResultado != null)
                    {
                        DataRSS = rsResultado.InnerText;
                        if (DataRSS.Length > 0)
                        {
                            DataRSS = Convert.ToDateTime(DataRSS).ToString();
                        }
                    }
                    else
                    {
                        DataRSS = "";
                    }
                    objBD.ExecutaSQL("EXEC sp_fmera_atualiza_noticias '" + TituloRSS + "','" + LinkRSS + "','" + DataRSS + "','',3");
                }
            }
            catch
            {
                throw;
            }
        }
开发者ID:kaizonaro,项目名称:animalbook,代码行数:65,代码来源:utils.cs

示例10: GetNameValuePair

		// This method gets the name value pair based on the first two attributes of every node
		public static NameValueCollection GetNameValuePair( XmlNodeList nodeList ) 
		{ 
			NameValueCollection nameVal = new NameValueCollection(); 
			if ( nodeList == null ) 
				return null; 
            
			// get parameter names
			XmlNode node = nodeList.Item( 0 ); 
			if ( node == null ) 
				return null; 
            
			XmlAttributeCollection attrCollection = node.Attributes; 
			if ( attrCollection == null ) 
				return null;
			if ( attrCollection.Count < 2 ) 
				return null;
            
			string attrName1 = null, attrName2 = null; 
			// read all nodes in nodelist and extract first two attributes
			foreach ( XmlNode n in nodeList ) 
			{ 
				attrName1 = n.Attributes[0].Value; 
				attrName2 = n.Attributes[1].Value; 
				nameVal.Add( attrName1, attrName2 ); 
			}
			return nameVal; 
		} 
开发者ID:icegithub,项目名称:csharp-exercise,代码行数:28,代码来源:XmlHelper.cs

示例11: GetDataTable

		/// -----------------------------------------------------------------------------
		/// <summary>s 
		/// Converts a list of Xml nodes to a DataTable.
		/// </summary>
		/// <param name="nodelist">List of Xml nodes</param>
		/// <returns>DataTable</returns>
		/// <remarks>
		/// This method convert
		/// </remarks>
		/// -----------------------------------------------------------------------------
		public static DataTable GetDataTable( XmlNodeList nodelist ) 
		{ 
			DataTable table = null; 
			XmlNode node = null; 
			if ( nodelist == null ) 
				return null;
            
			// get parameter names
			node = nodelist.Item( 0 ); 
			if ( node == null )
				return null;
            
			XmlAttributeCollection attrCollection = node.Attributes; 
			if ( attrCollection == null )
				return null;
			if ( attrCollection.Count == 0 ) 
				return null;
            
			// create data table
			table = new DataTable(); 
			foreach ( XmlAttribute attr in attrCollection )
			{ 
				table.Columns.Add( attr.Name ); 
			}
            
			// add rows
			DataRow row = null; 
			foreach ( XmlNode n in nodelist ) 
			{ 
				row = table.NewRow(); 
				foreach ( XmlAttribute a in n.Attributes ) 
				{ 
					row[a.Name] = a.Value; 
				}
				table.Rows.Add( row ); 
			}
            
			table.AcceptChanges(); 
			return table; 
		} 
开发者ID:icegithub,项目名称:csharp-exercise,代码行数:50,代码来源:XmlHelper.cs

示例12: CreateRegistrationParameters

		private void CreateRegistrationParameters(CodeExpressionCollection methodParameters, XmlNodeList scriptParameters)
		{
			CodeExpression[] initializers = new CodeExpression[scriptParameters.Count];

			for (int i = 0; i < scriptParameters.Count; i++)
			{
				if (scriptParameters.Item(i) is XmlElement)
				{
					XmlElement element = (XmlElement) scriptParameters.Item(i);

					if (PARAMETER.Equals(element.Name))
					{
						string key = element.GetAttribute(KEY);

						if (key != null && key.Length != 0)
						{
							initializers[i] = new CodeObjectCreateExpression(
								typeof (ComponentParameter),
								new CodeExpression[] {new CodePrimitiveExpression(key)});
						}
						else if (element.Value != null && element.Value.Length != 0)
						{
							initializers[i] = new CodeObjectCreateExpression(
								typeof (ConstantParameter),
								new CodeExpression[] {new CodeTypeOfExpression(element.Value)});
						}
						else
						{
							throw new PicoCompositionException("Parameter not set");
						}
					}
				}
			}

			methodParameters.Add(new CodeArrayCreateExpression(
				"IParameter",
				initializers));
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:38,代码来源:XMLContainerBuilder.cs

示例13: GetGradientStops

        private GradientStopCollection GetGradientStops(XmlNodeList stops)
        {
            int itemCount = stops.Count;
            GradientStopCollection gradientStops = new GradientStopCollection(itemCount);

            double lastOffset = 0;
            for (int i = 0; i < itemCount; i++)
            {
                SvgStopElement stop = (SvgStopElement)stops.Item(i);
                string prop = stop.GetAttribute("stop-color");
                string style = stop.GetAttribute("style");
                Color color = Colors.Transparent; // no auto-inherited...
                if (!String.IsNullOrEmpty(prop) || !String.IsNullOrEmpty(style))
                {
                    WpfSvgColor svgColor = new WpfSvgColor(stop, "stop-color");
                    color = svgColor.Color;
                }
                else
                {
                    color = Colors.Black; // the default color...
                    double alpha = 255;
                    string opacity;

                    opacity = stop.GetAttribute("stop-opacity"); // no auto-inherit
                    if (opacity == "inherit") // if explicitly defined...
                    {
                        opacity = stop.GetPropertyValue("stop-opacity");
                    }
                    if (opacity != null && opacity.Length > 0)
                        alpha *= SvgNumber.ParseNumber(opacity);

                    alpha = Math.Min(alpha, 255);
                    alpha = Math.Max(alpha, 0);

                    color = Color.FromArgb((byte)Convert.ToInt32(alpha),
                        color.R, color.G, color.B);
                }

                double offset = stop.Offset.AnimVal;

                offset /= 100;
                offset = Math.Max(lastOffset, offset);

                gradientStops.Add(new GradientStop(color, offset));
                lastOffset = offset;
            }

            if (itemCount == 0)
            {
                gradientStops.Add(new GradientStop(Colors.Black, 0));
                gradientStops.Add(new GradientStop(Colors.Black, 1));
            }

            return gradientStops;
        }
开发者ID:jogibear9988,项目名称:SharpVectors,代码行数:55,代码来源:WpfGradientFill.cs

示例14: refreshAirplanes

        public static void refreshAirplanes(List<Airplane> loadedAirplanes)
        {
            try
            {
                PlaneDocument.Load(@"Simulation\schedule.xml");
            }
            catch (FileNotFoundException)
            {
                return;
            }

            rawPlaneSchedule = PlaneDocument.GetElementsByTagName("plane");
            Assembly assembly = Assembly.Load("Introductieproject");

            int planeCount = rawPlaneSchedule.Count;
            for (int i = 0; i < planeCount; i++)
            {
                XmlNode rawAirplane = rawPlaneSchedule.Item(i);

                XmlAttributeCollection attr = rawAirplane.Attributes;

                String registration = attr["registration"].Value;
                String flight = attr["flight"].Value;
                String type = attr["type"].Value;
                String carrier = attr["carrier"].Value;
                String gate = attr["gate"].Value;
                String landingDate = attr["landingDate"].Value;
                String arrivalDate = attr["arrivalDate"].Value;
                String departureDate = attr["departureDate"].Value;
                String origin = attr["origin"].Value;
                String destination = attr["destination"].Value;
                String location = attr["location"].Value;

                DateTime landingDateTime = DateTime.Parse(landingDate);
                DateTime arrivalDateTime = DateTime.Parse(arrivalDate);
                DateTime departureDateTime = DateTime.Parse(departureDate);

                //Split landinglocation string to double[] location.
                string[] coords = location.Split(',');
                double[] landingLocation = new double[2];
                landingLocation[0] = double.Parse(coords[0]);
                landingLocation[1] = double.Parse(coords[1]);

                bool airplaneAlreadyLoaded = false;
                foreach (Airplane currentAirplane in loadedAirplanes)
                {
                    if (currentAirplane.Registration == null)
                    {
                        continue;
                    }
                        if (currentAirplane.Registration.Equals(registration))   // Airplane bestaat al
                        {
                            currentAirplane.flight = flight;
                            currentAirplane.carrier = carrier;
                            currentAirplane.landingDate = landingDateTime;
                            currentAirplane.arrivalDate = arrivalDateTime;
                            currentAirplane.departureDate = departureDateTime;
                            currentAirplane.origin = origin;
                            currentAirplane.destination = destination;

                            airplaneAlreadyLoaded = true;
                            break;
                        }
                }
                if (!airplaneAlreadyLoaded && TimeKeeper.currentSimTime < arrivalDateTime)
                {
                    System.Type objectType = assembly.GetType("Introductieproject.Objects." + type);

                    Airplane newAirplane = (Airplane)Activator.CreateInstance(objectType);
                    newAirplane.setXMLVariables(landingLocation, landingDateTime, gate, arrivalDateTime, departureDateTime, registration, flight, carrier, origin, destination);

                    loadedAirplanes.Add(newAirplane);
                }
            }
        }
开发者ID:quintstoffers,项目名称:Introductieproject,代码行数:75,代码来源:parser.cs

示例15: xmlNodeListToTable

        public static DataTable xmlNodeListToTable(XmlNodeList xmlNodeList, string tableName, DictionaryEntry colValPair)
        {
            DataTable dt = new DataTable(tableName);
            string colName = "";

            // Creating Columns and Table

            XmlNode tableDefinitionNode = xmlNodeList.Item(0);

            if (tableDefinitionNode == null) return null;

            foreach (XmlNode colDefNode in tableDefinitionNode.ChildNodes)
            {
                if (colValPair.Key == null)
                {
                    colName = colDefNode.Name;
                    //colValPair.Key = "id";
                    //colValPair.Value = colName;
                }
                else
                {
                    colName = getNodeAttributeValue(colDefNode, colValPair.Key.ToString());
                }
                DataColumn dc = new DataColumn(colName, System.Type.GetType("System.String"));
                dt.Columns.Add(dc);
            }

            int ColumnsCount = dt.Columns.Count;
            for (int i = 0; i < xmlNodeList.Count; i++)
            {
                DataRow dr = dt.NewRow();
                string curValue = "";
                for (int j = 0; j < ColumnsCount; j++)
                {
                    if (colValPair.Value == null)
                    {
                        colName = dt.Columns[j].ColumnName;
                    }
                    else
                    {
                        colName = colValPair.Value.ToString();
                    }

                    curValue = getNodeAttributeValue(xmlNodeList.Item(i).ChildNodes[j], colName);
                    if (j == 6 || j == 7)
                    {
                        dr[j] = attachClickEvent(curValue);
                    }
                    else
                    {
                        dr[j] = curValue;
                    }
                }
                dt.Rows.Add(dr);
            }
            return dt;
        }
开发者ID:aracen74,项目名称:Cerritosoft.Pdf.Test,代码行数:57,代码来源:BFXmlReader.cs


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