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


C# XmlReader.Read方法代码示例

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


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

示例1: ReadFromXml

        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "type")
                    {
                        var type = new ClassType();
                        type.ReadFromXml(reader);
                        classTypes.Add(type);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
开发者ID:GorelH,项目名称:schedule-metro,代码行数:28,代码来源:ClassTypes.cs

示例2: ExamQuestion

        public ExamQuestion(XmlReader reader)
            : this()
        {
            QuestionIdentifier = reader.GetAttribute("identifier");
            Question = reader.GetAttribute("question");
            Image = reader.GetAttribute("image");

            while (!reader.EOF)
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (reader.Name == "Answer")
                            Answer = reader.ReadElementContentAsString();
                        else if (reader.Name == "Distractor")
                            Distractors.Add(reader.ReadElementContentAsString());
                        else
                            reader.Read();
                        break;
                    case XmlNodeType.EndElement:
                        return;
                    default:
                        reader.Read();
                        break;
                }
            }
        }
开发者ID:jstoddard,项目名称:ExamCreator,代码行数:27,代码来源:ExamQuestion.cs

示例3: ReadCurrentNode

        internal XmlNode ReadCurrentNode(XmlDocument doc, XmlReader reader)
        {
            _doc = doc;
            _reader = reader;
            // WS are optional only for loading (see XmlDocument.PreserveWhitespace)
            _preserveWhitespace = true;
            if (doc == null)
                throw new ArgumentException(SR.Xdom_Load_NoDocument);
            if (reader == null)
                throw new ArgumentException(SR.Xdom_Load_NoReader);

            if (reader.ReadState == ReadState.Initial)
            {
                reader.Read();
            }
            if (reader.ReadState == ReadState.Interactive)
            {
                XmlNode n = LoadNode(true);

                // Move to the next node
                if (n.NodeType != XmlNodeType.Attribute)
                    reader.Read();

                return n;
            }
            return null;
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:27,代码来源:XmlLoader.cs

示例4: Task1

 public string Task1()
 {
     reader = XmlReader.Create(FILE_NAME);
     decimal in_v = 0;
     decimal out_v = 0;
     while (reader.Read())
     {
         if (reader.IsStartElement())
         {
             switch (reader.Name)
             {
                 case IN_V:
                     if(reader.Read())
                         in_v += Convert.ToDecimal(reader.Value.Trim());
                     break;
                 case OUT_V:
                     if (reader.Read())
                         out_v += Convert.ToDecimal(reader.Value.Trim());
                     break;
             }
         }
     }
     reader.Close();
     return IN_V + in_v.ToString() + "\n" + OUT_V + out_v.ToString();
 }
开发者ID:ErikCH,项目名称:XMLAssignment,代码行数:25,代码来源:Business.cs

示例5: Searchers

        public Searchers(XmlReader reader)
        {
            this.Choices = new List<Choice>();
            this.CurrentSearch = "";

            reader.Read();
            if (reader.Name != "TheSearchers")
                return; // bail out

            reader.Read();
            while (!reader.EOF)
            {
                if ((reader.Name == "TheSearchers") && !reader.IsStartElement())
                    break; // all done

                if (reader.Name == "Current")
                    this.CurrentSearch = reader.ReadElementContentAsString();
                else if (reader.Name == "Choice")
                {
                    string url = reader.GetAttribute("URL");
                    if (url == null)
                        url = reader.GetAttribute("URL2");
                    else
                    {
                        // old-style URL, replace "!" with "{ShowName}+{Season}+{Episode}"
                        url = url.Replace("!", "{ShowName}+{Season}+{Episode}");
                    }
                    this.Add(reader.GetAttribute("Name"), url);
                    reader.ReadElementContentAsString();
                }
                else
                    reader.ReadOuterXml();
            }
        }
开发者ID:madams74,项目名称:tvrename,代码行数:34,代码来源:Searchers.cs

示例6: readInFilepropertyElement

        public void readInFilepropertyElement(XmlReader reader, string dotName, Fileproperty fileproperty)
        {
            //while (reader.NodeType != XmlNodeType.EndElement)
            //{
                reader.Read();//now on text node
                if (reader.NodeType == XmlNodeType.Text)
                {
                    //Console.WriteLine(dotName + " = " + reader.Value);
                    switch (dotName)
                    {
                        case "Name":
                            fileproperty.Filename = reader.Value;
                            reader.Read();//now on end element like </Name>
                            break;
                        case "StartingFrame":
                            fileproperty.StartingFrame = Convert.ToInt32(reader.Value);
                            reader.Read();//now on end element like </Name>
                            break;
                        case "TotalFrames":
                            fileproperty.TotalFrames = Convert.ToInt32(reader.Value);
                            reader.Read();//now on end element like </Name>
                            break;

                    }
                }
            //}
            reader.Read();//now on the next start element like <StartingFrame>

        }
开发者ID:soudazhou,项目名称:Kinect-Analysis-Tool-for-Barbell-Weightlifting,代码行数:29,代码来源:XMLReader.cs

示例7: ParseElement

		/// <summary>
		///		Parses the WDDX element and returns the deserialized
		///		content as a <see cref="Hashtable"/> object, advancing the reader to the next
		///		element.
		/// </summary>
		/// <param name="input">The pre-initialized <see cref="System.Xml.XmlTextReader"/> pointing to the WDDX to be parsed.</param>
		public object ParseElement(XmlReader input)
		{
			Hashtable thisTable = new Hashtable();

			if (input.IsEmptyElement)
			{
				input.Skip();
				return thisTable;
			}

			string elementName;
			object elementValue;
			IWddxElementDeserializer deserializer;
			while (input.Read() && (!(input.Name == "struct" && input.NodeType == XmlNodeType.EndElement)))
			{
				if (input.Name == "var" && input.NodeType != XmlNodeType.EndElement)
				{
					elementName = input.GetAttribute("name");
					input.Read();  // move to contents of <var>
					deserializer = WddxElementDeserializerFactory.GetDeserializer(input.Name);
					elementValue = deserializer.ParseElement(input);
					thisTable.Add(elementName, elementValue);
				}
			}
			input.ReadEndElement();

			return thisTable;
		}
开发者ID:Bilal-S,项目名称:WDDX.net,代码行数:34,代码来源:StructDeserializer.cs

示例8: ReadXml

		public void ReadXml(XmlReader reader)
		{
			//goto inner hidden
			reader.Read();
		    Text = reader.ReadInnerXml();
			reader.Read();
		}
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:7,代码来源:Hidden.cs

示例9: while

 void IFlickrParsable.Load(XmlReader reader)
 {
     reader.Read();
       while (reader.LocalName != "photos")
       {
     switch (reader.LocalName)
     {
       case "firstdatetaken":
     this.FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
     continue;
       case "firstdate":
     this.FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
     continue;
       case "count":
     this.PhotoCount = reader.ReadElementContentAsInt();
     continue;
       case "views":
     this.Views = reader.ReadElementContentAsInt();
     continue;
       default:
     reader.Skip();
     continue;
     }
       }
       reader.Read();
 }
开发者ID:rmck,项目名称:FlickrNet,代码行数:26,代码来源:PersonPhotosSummary.cs

示例10: NoExtensionsSetup

		void NoExtensionsSetup ()
		{
			XmlReaderSettings xs = new XmlReaderSettings ();
			xs.IgnoreWhitespace = true;
			xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);

			xtr.Read ();

			//FIXME: skipping Headers
			while (xtr.LocalName != "Body") {
				if (!xtr.Read ())
					return;
			}

			//Move to <Metadata ..
			xtr.Read ();
			ms = MetadataSet.ReadFrom (xtr);

			//MyWsdlImportExtension mw = new MyWsdlImportExtension ();
			List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
			//list.Add (mw);
			list.Add (new DataContractSerializerMessageContractImporter ());

			/*list.Add (new MessageEncodingBindingElementImporter ());
			list.Add (new TransportBindingElementImporter ());
			list.Add (new StandardBindingImporter ());*/

			wi = new WsdlImporter (ms, null, list);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:WsdlImporterTest.cs

示例11: Deserialise

 public static void Deserialise(this PageInfo pageInfo, XmlReader reader)
 {
     if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("PageInfo"))
     {
         while (reader.Read() && reader.NodeType == XmlNodeType.Element)
         {
             string elementName = reader.Name;
             if (reader.Read() && reader.NodeType == XmlNodeType.Text)
             {
                 int value;
                 if (int.TryParse(reader.Value, out value))
                 {
                     switch (elementName)
                     {
                         case "TotalCount":
                             pageInfo.TotalCount = value;
                             break;
                         case "ItemsCount":
                             pageInfo.ItemsCount = value;
                             break;
                         case "StartIndex":
                             pageInfo.StartIndex = value;
                             break;
                     }
                 }
             }
             reader.Read();  // end element
         }
     }
 }
开发者ID:CreatorDev,项目名称:DeviceServer,代码行数:30,代码来源:PageInfoExtensions.cs

示例12: ReadFromXml

        public void ReadFromXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) { reader.Read(); return; }

            reader.Read();
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    if (reader.Name == "module")
                    {
                        var module = new Module();
                        module.ReadFromXml(reader);
                        modules.Add(module);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                else
                {
                    reader.Read();
                    break;
                }
            }
        }
开发者ID:GorelH,项目名称:schedule-metro,代码行数:28,代码来源:Modules.cs

示例13: while

        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "usage":
                        Usage = reader.ReadContentAsInt();
                        break;
                    case "predicate":
                        PredicateName = reader.Value;
                        break;
                    case "namespace":
                        NamespaceName = reader.Value;
                        break;
                }
            }

            reader.Read();

            if (reader.NodeType == XmlNodeType.Text)
                PairName = reader.ReadContentAsString();

            reader.Read();
        }
开发者ID:JamieKitson,项目名称:flickrnet-experimental,代码行数:25,代码来源:Pair.cs

示例14: ReadTerrain

        private void ReadTerrain(XmlReader reader, string key)
        {
            Terrain terrain = new Terrain (key);

            while (reader.Read ()) {
                if ((reader.NodeType == XmlNodeType.EndElement) &&
                    (reader.Name == "terrain"))
                    break;

                if (reader.NodeType != XmlNodeType.Element)
                    continue;

                string element = reader.Name;
                reader.Read ();

                if (element == "name")
                    terrain.Name = reader.Value;

                else if (element == "description")
                    terrain.Description = reader.Value;

                else if (element == "blocks")
                    terrain.IsBlocking = Boolean.Parse (reader.Value);

                else if (element == "tile")
                    terrain.Tiles.Add (reader.Value);
            }

            if (!terrain.IsValid)
                throw new ApplicationException (String.Format
                    ("Terrain '{0}' is missing a child element.",
                    key));

            terrains.Add (key, terrain);
        }
开发者ID:manicolosi,项目名称:questar,代码行数:35,代码来源:TerrainManager.cs

示例15: GetFeed

		public static IFeed GetFeed(Uri url, XmlReader reader) {
			reader.MoveToContent();
			string language = string.Empty;
			FeedType feedType;
			string namespaceUri = reader.NamespaceURI;
			if(reader.LocalName.Equals("RDF") &&
				reader.NamespaceURI.Equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) {
				feedType = FeedType.Rdf;
				reader.Read();
				reader.MoveToContent();
			} else if(reader.LocalName.Equals("rss")) {
				feedType = FeedType.Rss;

				do {
					reader.Read();
					reader.MoveToContent();
				} while(!reader.LocalName.Equals("channel") && !reader.LocalName.Equals("rss"));
			} else if(reader.NamespaceURI.Equals("http://purl.org/atom/ns#") && reader.LocalName.Equals("feed")) {
				if(reader.MoveToAttribute("version") && reader.Value.Equals("0.3")) {
					feedType = FeedType.Atom;
					language = reader.XmlLang;
					reader.MoveToElement();
				} else {
					throw new ApplicationException(string.Format("Unsupported Atom Version {0}", reader.Value));
				}
			} else if(reader.NamespaceURI.Equals("http://www.w3.org/2005/Atom") && reader.LocalName.Equals("feed")) {
				feedType = FeedType.Atom;
				language = reader.XmlLang;
			} else {
				throw new ApplicationException("Unknown Xml Dialect");
			}
			return PopulateFeed(url, reader, namespaceUri, feedType, language);
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:33,代码来源:FeedReader.cs


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