xmltextreader

Reading a xml file multithreaded

こ雲淡風輕ζ 提交于 2019-12-06 01:40:31
I've searched a lot but I couldn't find a propper solution for my problem. I wrote a xml file containing all episode information of a TV-Show. It's 38 kb and contains attributes and strings for about 680 variables. At first I simply read it with the help of XMLTextReader which worked fine with my quadcore. But my wifes five year old laptop took about 30 seconds to read it. So I thought about multithreading but I get an exception because the file is already opened. Thread start looks like this while (reader.Read()) { ... else if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.Equals(

convert xml to html using php

血红的双手。 提交于 2019-12-04 14:18:16
问题 I want to convert xml data into html. Below is sample xml data and I want to get/convert it in html format. <content type="html"> <paragraph id="1291266887"> <div class="red"> <span id="main_post_id"> <p>ten post przedstawia jak wysłać znaczników w ust <strong>Ling</strong> - xyz</p> <p>tags znane jako <span class="translation_section section_2">bezpieczne</span>, będą traktowane jako sekcje pkt</p> <p>innych materiałów dzielą się na <em>literach</em></p> </span> </div> </paragraph> </content

How to read a xml string into XMLTextReader type

六眼飞鱼酱① 提交于 2019-12-03 11:14:59
问题 I have an XML string. I need to convert this string into XMLTextReader (System.Xml.XMLTextReader) type in dotnet. I used the following code: string szInputXml = "<TestDataXml><DataName>testing</DataName></TestDataXml>" ; XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(szInputXml)); But the string inside the reader is empty after execution. Please help me to figure out what needs to be done to get the XMLTextReader to be populated with the given string. 回答1: How do you

Name cannot begin with the ' ' character

喜欢而已 提交于 2019-12-03 09:23:09
I'm parsing some XML in C#. I'm getting it from a database, and so converting it to a MemoryStream before reading it with an XmlTextReader. The problem is that I get this error: Name cannot begin with the ' ' character, hexadecimal value 0x20. Line 1, position 3. Following is my XML and my code for reading it (it's coming out of the database alright, no blank first character). Any suggestions? XML: <? xml version="1.0" encoding="utf-8" ?> <form> <e order="0" type="custom" name="test"> <fi type="text" /> <o /> </e> <e order="1" type="zip" /> <e order="2" type="state" /> </form> C#: byte[]

C# Foreach XML Node

馋奶兔 提交于 2019-11-30 08:50:00
I'm saving 2-dimensional coordinates on an XML file with a structure similar to: <?xml version="1.0" encoding="utf-8" ?> <grid> <coordinate time="78"> <initial>540:672</initial> <final>540:672</final> </coordinate> </grid> I can open the XML file and read it via the XmlTextReader, but how do I loop through the coordinates specifically to retrieve both the time attribute and data between the initial and final nodes in some format similar to: string initial = "540:672"; string final = "540:672"; int time = 78; New Code: My New Code: //Read the XML file. XDocument xmlDoc = XDocument.Load("C:\

C# Foreach XML Node

◇◆丶佛笑我妖孽 提交于 2019-11-29 12:38:41
问题 I'm saving 2-dimensional coordinates on an XML file with a structure similar to: <?xml version="1.0" encoding="utf-8" ?> <grid> <coordinate time="78"> <initial>540:672</initial> <final>540:672</final> </coordinate> </grid> I can open the XML file and read it via the XmlTextReader, but how do I loop through the coordinates specifically to retrieve both the time attribute and data between the initial and final nodes in some format similar to: string initial = "540:672"; string final = "540:672"

Fixing bad XML file (eg. unescaped & etc.) [duplicate]

大憨熊 提交于 2019-11-29 09:22:25
This question already has an answer here: How to parse invalid (bad / not well-formed) XML? 4 answers I got an XML file from 3rd party that I must import in my app, and XML had elements with unescaped & in inner text, and they don't wont to fix that ! So my question is what is the best way to deal with this problem ? This XML is pretty big and that fix has to be fast, my first solution is just replace & character with ampersand but really I don't like this "solution" for obvious reasons. I don't know how to use XmlStringReader with such XML because is throws exception on such lines, so I can't

XmlTextReader vs. XDocument

对着背影说爱祢 提交于 2019-11-27 04:49:31
I'm in the position to parse XML in .NET. Now I have the choice between at least XmlTextReader and XDocument . Are there any comparisons between those two (or any other XML parsers contained in the framework)? Maybe this could help me to decide without trying both of them in depth. The XML files are expected to be rather small, speed and memory usage are a minor issue compared to easiness of use. :-) (I'm going to use them from C# and/or IronPython.) Thanks! If you're happy reading everything into memory, use XDocument . It'll make your life much easier. LINQ to XML is a lovely API. Use an

Best Way to read rss feed in .net Using C#

女生的网名这么多〃 提交于 2019-11-27 02:34:12
What is the best way to read RSS feeds ? I am using XmlTextReader to achieve this. Is there any other best way to do it? XmlTextReader reader = new XmlTextReader(strURL); DataSet ds = new DataSet(); ds.ReadXml(reader); After reading the RSS feed using XmlTextReader , is there any way I can populate data to ListItem instead of DataSet ? The System.ServiceModel.Syndication namespace has some stuff for you, namely the SyndicationFeed class. This is a fairly simple example. http://blogs.msdn.com/b/steveres/archive/2008/01/20/using-syndicationfeed-to-displaying-photos-from-spaces-live-com.aspx

XmlTextReader vs. XDocument

别来无恙 提交于 2019-11-26 11:18:41
问题 I\'m in the position to parse XML in .NET. Now I have the choice between at least XmlTextReader and XDocument . Are there any comparisons between those two (or any other XML parsers contained in the framework)? Maybe this could help me to decide without trying both of them in depth. The XML files are expected to be rather small, speed and memory usage are a minor issue compared to easiness of use. :-) (I\'m going to use them from C# and/or IronPython.) Thanks! 回答1: If you're happy reading