• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Xml.XmlTextReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XmlTextReader类属于System.Xml命名空间,在下文中一共展示了XmlTextReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Deserialize

        public static IncomingTransportMessage Deserialize(string messageId, Stream inputStream)
        {
            var headers = new Dictionary<string, string>();
            var serializedMessageData = "";
            using (var reader = new XmlTextReader(inputStream))
            {
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.Read(); // read <root>
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        var elementName = reader.Name;
                        reader.Read(); // read the child;
                        while (reader.NodeType == XmlNodeType.Element)
                        {
                            // likely an empty header element node
                            headers.Add(elementName, reader.Value);

                            elementName = reader.Name;
                            reader.Read(); // read the child;
                        }
                        if (string.Equals(elementName, "body", StringComparison.InvariantCultureIgnoreCase) && reader.NodeType == XmlNodeType.CDATA)
                        {
                            serializedMessageData = reader.Value;
                        }
                        else if (reader.NodeType == XmlNodeType.Text)
                        {
                            headers.Add(elementName, reader.Value);
                        }
                    }
                }
            }
            return new IncomingTransportMessage(messageId, headers, serializedMessageData);
        }
开发者ID:jdaigle,项目名称:LightRail,代码行数:35,代码来源:FastXmlTransportMessageSerializer.cs


示例2: AvatarAnimations

        public AvatarAnimations()
        {
            using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(reader);
                foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
                {
                    if (nod.Attributes["name"] != null)
                    {
                        string name = nod.Attributes["name"].Value;
                        UUID id = (UUID) nod.InnerText;
                        string animState = nod.Attributes["state"].Value;

                        try
                        {
                            AnimsUUID.Add(name, id);
                            if (animState != "" && !AnimStateNames.ContainsKey(id))
                                AnimStateNames.Add(id, animState);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
开发者ID:KSLcom,项目名称:Aurora-Sim,代码行数:27,代码来源:AvatarAnimations.cs


示例3: Transform

        private static StringBuilder Transform(string gcmlPath)
        {
            if(!File.Exists(gcmlPath))
            {
                throw new GCMLFileNotFoundException("The GCML File" + gcmlPath + " does not exist.");
            }

            if(!File.Exists(xsltFilePath))
            {
                throw new XSLTFileNotFoundException("The XSLT File" + xsltFilePath + " does not exist.");
            }

            StringBuilder sb = new StringBuilder();
            XmlTextReader xmlSource = new XmlTextReader(gcmlPath);
            XPathDocument xpathDoc = new XPathDocument(xmlSource);
            XslCompiledTransform xsltDoc = new XslCompiledTransform();

            xsltDoc.Load(xsltFilePath);

            StringWriter sw = new StringWriter(sb);
            try
            {
                xsltDoc.Transform(xpathDoc, null, sw);
            }
            catch (XsltException except)
            {
                Console.WriteLine(except.Message);
                throw except;
            }

            return sb;
        }
开发者ID:radtek,项目名称:rrcomssys-team-5,代码行数:32,代码来源:SchemaTransformer.cs


示例4: RepertoireRepository

 public RepertoireRepository()
 {
     XmlReader reader = new XmlTextReader(path);
     List<TheaterRepertoire> filereprt = (List<TheaterRepertoire>)writers.Deserialize(reader);
     reader.Close();
     this.repertoiresList = filereprt;
 }
开发者ID:Taturevich,项目名称:TrainingProject,代码行数:7,代码来源:RepertoireRepository.cs


示例5: advanceToElement

 private void advanceToElement(ref XmlTextReader reader, string element)
 {
     while (!reader.Name.EndsWith(element))
     {
         reader.Read();
     }
 }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:7,代码来源:NUnitLogParser.cs


示例6: LoadChannels

 private static void LoadChannels()
 {
     XmlReader reader = new XmlTextReader("channel.xml");
     while (reader.Read())
     {
         switch (reader.Name)
         {
             case "CHANNEL":
                 MMatchChannel channel = new MMatchChannel();
                 channel.szName = reader.GetAttribute("name");
                 if (!Int32.TryParse(reader.GetAttribute("levelmin"), out channel.nMinLevel))
                     channel.nMinLevel = 0;
                 channel.nMaxUsers = Int32.Parse(reader.GetAttribute("maxplayers"));
                 channel.uidChannel = Convert.ToUInt64(mChannels.Count);
                 channel.nChannelType = MMatchChannelType.General;
                 switch (reader.GetAttribute("rule"))
                 {
                     case "elite":
                         channel.nChannelRule = MMatchChannelRule.Elite;
                         break;
                 }
                 mChannels.Add(channel);
                 break;
         }
     }
 }
开发者ID:Theoretical,项目名称:Infamous,代码行数:26,代码来源:Program.cs


示例7: Parse

        public List<ProgramElement> Parse(string filename)
        {
            var programElements = new List<ProgramElement>();

            XmlTextReader reader = new XmlTextReader(filename);

            while (reader.Read())
            {
                string text = String.Empty;

                if (reader.NodeType == XmlNodeType.Text)
                {
                    text = reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        text += reader.Value + " ";
                    }
                }

                if (!String.IsNullOrWhiteSpace(text))
                {
                    var cleanedText = text.TrimStart(' ', '\n', '\r', '\t');
                    cleanedText = cleanedText.TrimEnd(' ', '\n', '\r', '\t');
                    var linenum = reader.LineNumber;
                    var snippet = SrcMLParsingUtils.RetrieveSource(cleanedText);
                    var pe = new TextFileElement(filename, snippet, cleanedText);
                    programElements.Add(pe);
                }
            }

            return programElements;
        }
开发者ID:spati2,项目名称:FSE-2012-SANDO,代码行数:35,代码来源:XMLFileParser.cs


示例8: CategoriesInfoRepository

 public CategoriesInfoRepository()
 {
     XmlReader reader = new XmlTextReader(path);
     List<CategoryInfo> infoFromXml = (List<CategoryInfo>)writers.Deserialize(reader);
     reader.Close();
     this.categoriesInfolList = infoFromXml;
 }
开发者ID:Taturevich,项目名称:TrainingProject,代码行数:7,代码来源:CategoriesInfoRepository.cs


示例9: ReadTokensFromXML

        private string ReadTokensFromXML()
        {
            string tokens = String.Empty;

            try
            {
                XmlTextReader tokensXmlReader = new XmlTextReader(String.Format(@"{0}\{1}",
                                                                  System.IO.Directory.GetCurrentDirectory(),
                                                                  xmlName));
                while (tokensXmlReader.Read())
                {
                    if (tokensXmlReader.NodeType == XmlNodeType.Element && tokensXmlReader.Name == "token")
                    {
                        tokens += String.Format("Token \"{0}\"\n \tLine: {1}\n \tPosition: {2}\n \tValue: {3}\n\n",
                                                tokensXmlReader.GetAttribute("type"),
                                                Convert.ToString(Convert.ToInt32(tokensXmlReader.GetAttribute("line")) + 1),
                                                tokensXmlReader.GetAttribute("position"),
                                                tokensXmlReader.GetAttribute("value"));
                    }
                }

                tokensXmlReader.Close();
                return tokens;
            }
            catch
            {
                return "";
            }
        }
开发者ID:Throttle,项目名称:compiler,代码行数:29,代码来源:LexicalAnalyser.cs


示例10: visualizeDo_Click

        protected void visualizeDo_Click(object sender, EventArgs e)
        {

            // get xslt file
            string xslt = "";
            if (xsltSelection.Value.Contains("<xsl:stylesheet"))
            {
                xslt = xsltSelection.Value;
            }
            else
            {
                System.IO.StreamReader xsltFile =
                System.IO.File.OpenText(
                    IOHelper.MapPath(SystemDirectories.Umbraco + "/xslt/templates/clean.xslt")
                );

                xslt = xsltFile.ReadToEnd();
                xsltFile.Close();

                // parse xslt
                xslt = xslt.Replace("<!-- start writing XSLT -->", xsltSelection.Value);

                // prepare support for XSLT extensions
                xslt = macro.AddXsltExtensionsToHeader(xslt);

            }

            Dictionary<string, object> parameters = new Dictionary<string, object>(1);
            parameters.Add("currentPage", library.GetXmlNodeById(contentPicker.Value));


            // apply the XSLT transformation
            string xsltResult = "";
            XmlTextReader xslReader = null;
            try
            {
                xslReader = new XmlTextReader(new StringReader(xslt));
                System.Xml.Xsl.XslCompiledTransform xsl = macro.CreateXsltTransform(xslReader, false);
                xsltResult = macro.GetXsltTransformResult(new XmlDocument(), xsl, parameters);
            }
            catch (Exception ee)
            {
                xsltResult = string.Format(
                    "<div class=\"error\"><h3>Error parsing the XSLT:</h3><p>{0}</p></div>",
                    ee.ToString());
            }
            finally
            {
                xslReader.Close();
            }
            visualizeContainer.Visible = true;

            // update output
            visualizeArea.Text = !String.IsNullOrEmpty(xsltResult) ? "<div id=\"result\">" + xsltResult + "</Div>" : "<div class=\"notice\"><p>The XSLT didn't generate any output</p></div>";


            // add cookie with current page
			// zb-00004 #29956 : refactor cookies names & handling
			cookie.SetValue(contentPicker.Value);
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:60,代码来源:xsltVisualize.aspx.cs


示例11: Read_Metadata

        /// <summary> Reads metadata from an open stream and saves to the provided item/package </summary>
        /// <param name="Input_Stream"> Open stream to read metadata from </param>
        /// <param name="Return_Package"> Package into which to read the metadata </param>
        /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param>
        /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during reading </param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        public bool Read_Metadata(Stream Input_Stream, SobekCM_Item Return_Package, Dictionary<string, object> Options, out string Error_Message)
        {
            // Set default error outpt message
            Error_Message = String.Empty;

            // Create a XML reader and read the metadata
            XmlTextReader nodeReader = null;
            bool returnValue = true;
            try
            {
                // create the node reader
                nodeReader = new XmlTextReader(Input_Stream);
                MODS_METS_dmdSec_ReaderWriter.Read_MODS_Info(nodeReader, Return_Package.Bib_Info, Return_Package);
            }
            catch (Exception ee)
            {
                Error_Message = "Error reading MODS from stream: " + ee.Message;
                returnValue = false;
            }
            finally
            {
                if (nodeReader != null)
                    nodeReader.Close();
            }

            return returnValue;
        }
开发者ID:Elkolt,项目名称:SobekCM-Web-Application,代码行数:33,代码来源:MODS_File_ReaderWriter.cs


示例12: ScanDirectory

		List<SyntaxMode> ScanDirectory(string directory)
		{
			string[] files = Directory.GetFiles(directory);
			List<SyntaxMode> modes = new List<SyntaxMode>();
			foreach (string file in files) {
				if (Path.GetExtension(file).Equals(".XSHD", StringComparison.OrdinalIgnoreCase)) {
					XmlTextReader reader = new XmlTextReader(file);
					while (reader.Read()) {
						if (reader.NodeType == XmlNodeType.Element) {
							switch (reader.Name) {
								case "SyntaxDefinition":
									string name       = reader.GetAttribute("name");
									string extensions = reader.GetAttribute("extensions");
									modes.Add(new SyntaxMode(Path.GetFileName(file),
									                         name,
									                         extensions));
									goto bailout;
								default:
									throw new HighlightingDefinitionInvalidException("Unknown root node in syntax highlighting file :" + reader.Name);
							}
						}
					}
				bailout:
					reader.Close();
					
				}
			}
			return modes;
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:29,代码来源:FileSyntaxModeProvider.cs


示例13: FromXml

        private void FromXml(String xmlStream)
        {
            try
            {
                StringReader stringReader = new StringReader(xmlStream);
                XmlTextReader reader = new XmlTextReader(stringReader);
                while (reader.EOF == false)
                {
                    reader.ReadStartElement("ValidationContext");
                    String generateSummaryResults = reader.ReadElementString("GenerateSummaryResults");
                    if (generateSummaryResults == "true")
                    {
                        _generateSummaryResults = true;
                    }
                    String generateDetailedResults = reader.ReadElementString("GenerateDetailedResults");
                    if (generateDetailedResults == "true")
                    {
                        _generateDetailedResults = true;
                    }
                    // ...
                    // EVS Specific Context properties
                    // ...
                    reader.ReadElementString("EvsSpecificContext");

                    reader.ReadEndElement();
                }
                reader.Close();
            }
            catch (Exception e)
            {
                String message = String.Format("Failed to FromXml() DVTK DICOM EVS Validation Context XML stream: \"{0}\". Error: \"{1}\"", xmlStream, e.Message);
                throw new Exception(message, e);
            }
        }
开发者ID:ewcasas,项目名称:DVTK,代码行数:34,代码来源:DvtkValidationContext.cs


示例14: CreateInstance

 /// <summary>
 /// Creates an instance of the given type from the specified Internet resource.
 /// </summary>
 /// <param name="htmlUrl">The requested URL, such as "http://Myserver/Mypath/Myfile.asp".</param>
 /// <param name="xsltUrl">The URL that specifies the XSLT stylesheet to load.</param>
 /// <param name="xsltArgs">An <see cref="XsltArgumentList"/> containing the namespace-qualified arguments used as input to the transform.</param>
 /// <param name="type">The requested type.</param>
 /// <param name="xmlPath">A file path where the temporary XML before transformation will be saved. Mostly used for debugging purposes.</param>
 /// <returns>An newly created instance.</returns>
 public object CreateInstance(string htmlUrl, string xsltUrl, XsltArgumentList xsltArgs, Type type,
                              string xmlPath)
 {
     StringWriter sw = new StringWriter();
     XmlTextWriter writer = new XmlTextWriter(sw);
     if (xsltUrl == null)
     {
         LoadHtmlAsXml(htmlUrl, writer);
     }
     else
     {
         if (xmlPath == null)
         {
             LoadHtmlAsXml(htmlUrl, xsltUrl, xsltArgs, writer);
         }
         else
         {
             LoadHtmlAsXml(htmlUrl, xsltUrl, xsltArgs, writer, xmlPath);
         }
     }
     writer.Flush();
     StringReader sr = new StringReader(sw.ToString());
     XmlTextReader reader = new XmlTextReader(sr);
     XmlSerializer serializer = new XmlSerializer(type);
     object o;
     try
     {
         o = serializer.Deserialize(reader);
     }
     catch (InvalidOperationException ex)
     {
         throw new Exception(ex + ", --- xml:" + sw);
     }
     return o;
 }
开发者ID:ToFuKing,项目名称:HtmlAgilityPack,代码行数:44,代码来源:HtmlWeb.Xpath.cs


示例15: Parser

 public Parser(XmlTextReader reader)
 {
     this.reader = reader;
     this.reader.WhitespaceHandling = WhitespaceHandling.None;
        // 'None' only prevents whitespace  being returned as a node
        // Now assuming that there is no embedded whitespace that isn't significant.
 }
开发者ID:wshanshan,项目名称:DDD,代码行数:7,代码来源:ParserRoutines.cs


示例16: ProcessRecord

        protected override void ProcessRecord()
        {
            const BindingFlags commonBindings = BindingFlags.NonPublic | BindingFlags.Instance;
            const BindingFlags methodBindings = BindingFlags.InvokeMethod | commonBindings;
            var type = typeof(PSObject).Assembly.GetType("System.Management.Automation.Deserializer");
            var ctor = type.GetConstructor(commonBindings, null, new[] { typeof(XmlReader) }, null);

            using (var sr = new StringReader(InputObject))
            {
                using (var xr = new XmlTextReader(sr))
                {
                    var deserializer = ctor.Invoke(new object[] { xr });
                    while (!(bool)type.InvokeMember("Done", methodBindings, null, deserializer, new object[] { }))
                    {
                        try
                        {
                            WriteObject(type.InvokeMember("Deserialize", methodBindings, null, deserializer, new object[] { }));
                        }
                        catch (Exception ex)
                        {
                            WriteWarning("Could not deserialize string. Exception: " + ex.Message);
                        }
                    }
                }
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:26,代码来源:ConvertFromCliXmlCommand.cs


示例17: 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


示例18: GetObject

        public void GetObject(string strResource, string strID, string strType)
        {
            string requestArguments = "?Resource=" + strResource + "&ID=" + strID + "&Type=" + strType;
            string searchService = RetsUrl + "/GetObject.svc/GetObject" + requestArguments;

            httpWebRequest = (HttpWebRequest)WebRequest.Create(searchService);
            httpWebRequest.CookieContainer = cookieJar; //GRAB THE COOKIE
            httpWebRequest.Credentials = requestCredentials; //PASS CREDENTIALS

            try
            {
                using (HttpWebResponse httpResponse = httpWebRequest.GetResponse() as HttpWebResponse)
                {

                    // READ THE RESPONSE STREAM USING XMLTEXTREADER
                    if (httpResponse.StatusCode == HttpStatusCode.OK)
                    {
                        Stream stream = httpResponse.GetResponseStream(); // READ THE RESPONSE STREAM USING STREAMREADER
                        StreamReader reader = new StreamReader(stream);
                        XmlTextReader reader2 = new XmlTextReader(stream);
                        XmlDocument doc = new XmlDocument();
                        doc.Load(reader);
                        doc.Save(HttpContext.Current.Server.MapPath(strResource + "Obj.xml"));
                        Console.WriteLine("Received photo -> resource:" + strResource + ", type: " + strType);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
开发者ID:devnarayan,项目名称:CREA-Real-Estate,代码行数:32,代码来源:DataFeed.cs


示例19: OnStartUp

        public void OnStartUp()
        {
            SetRootPathProject();

            XmlTextReader configReader = new XmlTextReader(new MemoryStream(NHibernate.Test.Properties.Resources.Configuration));
            DirectoryInfo dir = new DirectoryInfo(this.rootPathProject + ".Hbm");
            Console.WriteLine(dir);

            builder = new NhConfigurationBuilder(configReader, dir);

            builder.SetProperty("connection.connection_string", GetConnectionString());

            try
            {
                builder.BuildSessionFactory();
                sessionFactory = builder.SessionFactory;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            
            sessionProvider = new SessionManager(sessionFactory);
            currentPagedDAO = new EnterprisePagedDAO(sessionProvider);
            currentRootPagedDAO = new EnterpriseRootDAO<object>(sessionProvider);
            currentSession = sessionFactory.OpenSession();
        }
开发者ID:TheHunter,项目名称:PersistentLayer.NHibernate,代码行数:28,代码来源:CurrentTester.cs


示例20: GetEprSchema

 static XmlSchema GetEprSchema()
 {
     using (XmlTextReader reader = new XmlTextReader(new StringReader(Schema)) { DtdProcessing = DtdProcessing.Prohibit })
     {
         return XmlSchema.Read(reader, null);
     }
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:7,代码来源:EndpointAddressAugust2004.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Xml.XmlTextReaderImpl类代码示例发布时间:2022-05-27
下一篇:
C# Xml.XmlText类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap