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


C# XmlNodeReader.ReadInnerXml方法代码示例

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


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

示例1: GetXml

        /// <summary>
        /// 获取XML
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <returns></returns>
        // xmlFile = HttpContext.Server.MapPath("~/Student.xml")
        public string GetXml(string xmlFile)
        {
            string id = "";
            string Info = "";

            if (XmlDoc == null)
            {
                lock (DocLock)
                {
                    if (XmlDoc == null)
                    {
                        XmlDoc = new XmlDocument();
                        XmlDoc.Load(xmlFile);
                    }
                }
            }

            string Name = string.Empty;
            string _id = string.Empty;
            XmlElement root = XmlDoc.DocumentElement;
            XmlNodeList personNodes = root.GetElementsByTagName("person");
            foreach (XmlNode node in personNodes)
            {
                if (((XmlElement)node).GetAttribute("id") == "2" || ((XmlElement)node).GetAttribute("id") == "4")
                {
                    Name += ((XmlElement)node).InnerText;
                    _id += ((XmlElement)node).GetAttribute("id");
                    var str = node.GetEnumerator();
                }
            }

            XmlNodeReader ParaReader = new XmlNodeReader(XmlDoc);
            while (ParaReader.Read())
            {
                if (ParaReader.NodeType == XmlNodeType.Element && ParaReader.Name == "person")
                {
                    if (!string.IsNullOrEmpty(ParaReader.GetAttribute("id")))
                    {
                        id += ParaReader.GetAttribute("id") + "+";
                        Info += ParaReader.ReadInnerXml() + "+";

                    }
                    //if (f == "PaymentDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute(1);//Info = ParaReader.GetAttribute(1).Replace("{2}", Member.ValidBeginDate + "");//缴费
                    //if (f == "ReplacementDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value");//Info = ParaReader.GetAttribute("value").Replace("{2}", Member.ValidBeginDate + "").Replace("{3}", Member.ReplacementDate + "");  //换证 
                    //if (f == "ContributionsDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value"); //体检 
                }
                string str = ParaReader.GetAttribute("id") + ParaReader.GetAttribute("sex") + ParaReader.ReadInnerXml();
            }
            ParaReader.Close();
            return System.Text.Encoding.GetEncoding("gb2312").GetString(System.Text.Encoding.Default.GetBytes(id + "\n" + Info));
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:57,代码来源:XmlHelper.cs

示例2: ReadInnerXmlWrongInit

		public void ReadInnerXmlWrongInit ()
		{
			document.LoadXml ("<root>test of <b>mixed</b> string.</root>");
			XmlNodeReader nrdr = new XmlNodeReader (document);
			nrdr.ReadInnerXml ();
			Assert.AreEqual (ReadState.Initial, nrdr.ReadState, "initial.ReadState");
			Assert.AreEqual (false, nrdr.EOF, "initial.EOF");
			Assert.AreEqual (XmlNodeType.None, nrdr.NodeType, "initial.NodeType");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:XmlNodeReaderTests.cs

示例3: Main

        static void Main(string[] args)
        {
            var artists = new List<string>();
            var albums = new List<string>();

            var catalogFilePath = "../../../../catalog.xml";
            XmlDocument doc = new XmlDocument();
            doc.Load(catalogFilePath);
            using (XmlNodeReader reader = new XmlNodeReader(doc))
            {
                reader.MoveToContent();
                reader.ReadToDescendant("album");

                while (reader.Read())
                {
                    var albumName = reader.ReadInnerXml();
                    albums.Add(albumName);

                    var artist = reader.ReadInnerXml();
                    artists.Add(artist);

                    reader.ReadToFollowing("album");
                }
            }

            string albumFilePath = "../../album.xml";
            Encoding encoding = Encoding.GetEncoding("windows-1251");
            using (XmlTextWriter writer = new XmlTextWriter(albumFilePath, encoding))
            {
                writer.Formatting = Formatting.Indented;
                writer.IndentChar = '\t';
                writer.Indentation = 1;

                writer.WriteStartDocument();
                writer.WriteStartElement("albums");
                for (int i = 0, len = artists.Count; i < len; i++)
                {
                    WriteAlbum(writer, albums[i], artists[i]);
                }
                writer.WriteEndDocument();
            }

            Console.WriteLine("Document {0} created.", albumFilePath);
        }
开发者ID:NK-Hertz,项目名称:Telerik-Academy-2015,代码行数:44,代码来源:Program.cs


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