xmltextreader

XMLTextReader in .NET 1.1

I have a process that reads an XML file. It uses the XMLTextReader class to do this as it is supposed to be a fast, forward only XML parser/reader. Works just great with a 1 megabyte test file but comes to a complete halt when working on a 12 meg file in the live system. Are there any solutions to this other than writing my own XML rea...

Hash character in path throws DirectoryNotFoundException

Consider the following code snippet private void ProcessFile(string fullPath) { XmlTextReader rdr = new XmlTextReader("file:\\\\" + fullPath); while (rdr.Read()) { //Do something } return; } Now, this functions fine when passed a path like: "C:\Work Files\Technical Information\Dummy.xml" But throws an error w...

WPF - Searching an XML doc for values using XMLTextReader

Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL. I want to get multiple values out of the document (weather data, location, some other strings). When I use the XmlTextReader I can call my method to pull the values out. The first time I pass the method to search for the xml no...

Large XML file, XmlDocument not feasible but need to be able to search

I am struggling with a sensible logic loop for stripping out nodes from an XML file too large to use with XPath supporting .NET classes. I am attempting to replace the single line of code I had (that called SelectNodes with an XPath query string) with code that does the same but uses an XmTextReader. I have to go several levels down as...

XmlTextReader - Does it lock the file?

This is probably a really simple thing, but I haven't been able to find it, and I'm probably just searching for the wrong thing... XmlTextReader --> Does it lock the file you're reading? I'm using reader.Read() and that's about it. ...

How do I output XML as a string from an XmlTextReader into a Response.Write?

I have retrieved some XML from an API (at least I think so, the server response is 'OK') however I am putting the response stream into an XmlTextReader, how do I output this XML as a string? ...

Root element is missing error for .net XmlDocument.load()

Greetings all. I'm getting an asp.net error "Root element is missing" when I load the results of a REST request into an XmlDocument. The same REST request looks fine and returns valid results when I execute it using the Firefox addon "RESTTEST". But the error shows up in the C#.net code-behind. Does anyone know what might cause this?...

Load XmlTextReader from a file in my web app via a method in another DLL

I am creating a method in a DLL that is going to be dropped into a web application. The web application has a folder with a XML file in it: /files/myfile.xml My dll has to reference that DLL, but I can't hard code the path to the file obviously. How can I reference that file and load a XmlTextReader with that file? ...

how to load a hashtable from a simple xml file using xmltextreader

Hi, using xmltextreader, how would I load a hashtable. XML: <base><user name="john">2342343</user><user name="mark">239099393</user></base> This was asked before but it was using some funky linq that I am not fully comfortable with just yet. ...

How can I read in C# XML from another page while logged in to the site

I have logged in to the site with my webbrowser and whenever I try to call WebClient myWebClient = new WebClient(); string str = myWebClient.DownloadString("http://localhost/myxml.aspx"); Response.Write(str.ToString()); Or XmlTextReader reader = new XmlTextReader(url); while (reader.Read()) { Response.Write(reader.ReadOuterXml()); ...

Merging XMLTextReaders in C#

I have a website that needs to pull information from two diffferent XML data sources. Originally I only need to get the data from one source so I was building a URL in the backend that went and retrieved the data from the XML site and then parsed and rendered it in the front end of the website. Now I have to use a 2nd data source and me...

convert XmlReader to XmlTextReader

How do you convert XmlReader to XmlTextReader? Code Snippet: XmlTextReader reader = XmlTextReader.Create(pomfile.FullName); Here's the Build error I got: Cannot implicitly convert type 'System.Xml.XmlReader' to 'System.Xml.XmlTextReader'. An explicit conversion exists(are you missing a cast?). pomfile is of type FileInfo ...

C# Foreach XML Node

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 specifica...

Name cannot begin with the ' ' character

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 data...

Reading XML file faster in ASP.NET

Hi all, I have multiple XML files that I need to parse. Problem is that I only need some data in the last couple of lines. I currently use XMLTextReader and reader.ReadToFollowing("DATANEEDED"); but it is still too slow. Does anyone know if I can 'tail' an XML file and read from there? (taking into account the tail would not be a ...

Can XmlTextReader tell the difference between <tag> and <tag />

I am reading an XML file using an XMLTextReader. Is there a way to tell the difference between a start tag (like <tag>) and a self-terminating tag (like <tag />) ...

why does xmltextreader convert html encoded utf8 characters to utf8 string automatically?!!

I receive an XML file with encoding "ISO-8859-1" (Latin-1) Within the file (among other tags) I have <OtherText>Example &quot;content&quot; And &#9472;</OtherText> Now for some reason when I load this into XMLTextReader and do a "XmlReader.Value" to return the value, it returns: "content" And ─ This then, when confronted with a datab...

XML Reader Performance

I've traced slugishness in my application to the bit of code that's being timed below. I knew that this would be a slow point but each request is taking an average of 1 second. The bit of xml that I'm after is always in the first tag so I don't think it's the download times that are getting me. Stopwatch stopwatch = new Stopwatch(); Xml...

XmlTextReader for json?

Is there something that is similar to XmlTextReader in terms of performance, but using JSON instead? I have the choice between parsing data in XML or parsing the same data in JSON. I'd like to use JSON because I figure I could save a bit of bandwidth but I'd like to keep the performance of XmlTextReader. In other words, how do I stream...

XMLTextReader not reading an element content

static void ReadXml() { string a= null; double b= 0; double c= 0; XmlReader xmlReader = new XmlReader("Testxml.xml"); xmlReader. using (xmlReader) { if (xmlReader != null) { while (xmlReader.Read()) { ...