xmlreader

XmlReader and MemoryStream, the returned xml misses tags

Could someone explain this behaviour to me? If you execute the snippet at the bottom of the post with the first string, it returns the exact same string as the one used for the input; that's what I expected. input 1: <?xml version='1.0' encoding='UTF-8'?> <Company> <Creator>Me</Creator> <CreationDateTime>2010-01-25T21:58:32.493</...

Correcting XmlReader problems using ReadToDescendant and/or ReadElementContentAsObject

I'm working on a mysterious bug in the usually very good open source project Excel Data Reader. It's skipping values reading from my particular OpenXML .xlsx spreadsheet. The problem is occurring in the ReadSheetRow method (demonstration code below). The source XML is saved by Excel and contains no whitespace which is when the strange b...

How to remove whitespace from XElement object created from XElement.ReadFrom(XmlReader)

I am parsing a large xml file. So I am using an XmlReader in combination with XElement instead of XElement.Load(). I have created as XElement object from XmlReader as shown below and here. static IEnumerable<XElement> StreamRootChildDoc(string uri) { using (XmlReader reader = XmlReader.Create(uri, xmlReaderSettings)) { ...

How to make second test passing in these C# Xml unit tests? What do I miss in initialization of XmlReaderSettings?

Issue description: I need to fix an issue with resolving of standard HTML entitities. I've implemented HtmlEntityReader - implementation of XmlReader which has a code to resolve entities Public API of our system provides a methods with usage of XmlReader, so user can pass XmlReader created using one of the XmlReader.Create methods ...

Why doesn't my XmlReader.GetAttribute() return a value?

I'm trying to parse my XML in C#. Here's part of the file that is relevant: <holder name="wnd_login" width="300" x="20" height="180">...</holder> Here's the code that is supposed to read it: while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "holder": ...

Get tag name and value of a given node using XMLReader, DOM, Xpath

I need to query an xml document and then display specific tag values, e.g. forename, surname, group(dept), job_title. I'm using XMLReader as i may need to work with large XML files. I using DomXPath to filter the data, but i don't know how to retrieve the nodeName and value for each element. The code below only returns 'member' as the...

Why is XmlReader appending namespace uris to each element?

I've got a Stream containing xml in the following format that I want to deserialize into C# objects <?xml version="1.0" encoding="utf-8" standalone="yes"?> <OrganisationMetaData xmlns="urn:organisationMetaDataSchema"> <Organisations> <Organisation> <Code>XXX</Code> <Name>Yyyyyy</Name>... I've done this loads of t...

Should I output cache my control that looks up twitter RSS onload?

I have a user control that is featured on several pages of a heavily hit site. Some of these pages include our blog sidebar, our forum sidebar, and smack right in the middle of our home page. That means this control is rendered a lot. The control it meant to read in a twitter RSS feed for a specific account and write out the last 2 tweet...

Reading Xml with XmlReader in C#

I'm trying to read the following Xml document as fast as I can and let additional classes manage the reading of each sub block. <ApplicationPool> <Accounts> <Account> <NameOfKin></NameOfKin> <StatementsAvailable> <Statement></Statement> </StatementsAvailable> </Acco...

XML/C#: Read content if only if attribute is correct

Hi Guys, I have an XML file as follows, and I'm trying to read the content of the Name tag, only if the attribute of the Record tag is what I want. (continued below code) The XML file is: <?xml version="1.0" encoding="utf-8" ?> <Database> <Record Number="1"> <Name>John Doe</Name> <Position>1</Position> <HoursWorked>290</...

Parsing XML with the PHP XMLReader

Hi Guys, I am writing program that reads in some XML from the $_POST variable and then parses using the PHP XMLReader and the data extracted input into a database. I am using the XMLReader as the XML supplied will more than likely be too big to place into memory. However I am having some issues, my XML and basic code as are follows: ...

Using PHP's XMLReader, how do I get the line number of the current node?

Using the XMLReader XML parser in PHP 5.3, I need to get the line number of the current node. A column number or total offset from the beginning of the file would be nice, too. Hopefully I don't have to use some hack like parsing every raw node string for newlines (with readOuterXML()), but I don't see a getLineNo() property like in th...

.NET: What is the purpose of the ProhibitDtd property in XmlReaderSettings? Why is DTD a security issue?

The documentation says: When set to true, the XmlReader throws an XmlException when any DTD content is encountered. Do not enable DTD processing if you are concerned about Denial of Service issues or if you are dealing with untrusted sources. If you have DTD processing enabled, you can use the XmlSecureResolver to restrict the...

XmlReader skipping/ignoring attr/element on Error?

I am running xhtml-strict report on a bunch of pages and each time I find a page on a specific page I save it. I need to really look over all the page but what happens is that sometimes the XmlReader is failling but I cannot go on and check the rest of the file to report the errors. I have Eventhandler catching dtd errors when found. th...

Is there a fast way to jump to element using XMLReader?

I am using XMLReader to read a large XML file with about 1 million elements on the level I am reading from. However, I've calculated it will take over 10 seconds when I jump to -for instance- element 500.000 using XMLReader::next ([ string $localname ] ) or XMLReader::read ( void ) This is not very usable. Is there a faster way to...

XMLReader expand() issues -- produces Warning: DOM support is not enabled

I'm new to XMLReader and novice at PHP. I'm trying to figure out how to use XMLReader to parse XML files. In particular, I'm trying to grab particular nodes of a very large XML file so that I can rewrite a smaller file with just the subset of nodes I need. So, XMLReader seemed appealing for its supposed speed with $reader->expand(). ...

XML Reader or Linq to XML

I have a 150MB XML file which used asDB in my project. Currently I'm using XMLReader to read content from it. I want to know it is better to use XMLReader or LinqToXML for this scenario. Note that I'm searching for an item in this xmland display search result, soitcan be take along or just a moment. ...

problem parsing with XMLReader (using ReadSubTree)

Hello. Im trying to build a simple XML to Controls parser in my CF application. In the code below the string im trying to parse looks like this: "<Panel><Label>Text1</Label><Label>Text2</Label></Panel>" The result i want with this code would be a Panel with two labels. But the problem is when the first Label is parsed the subreader.R...

XMLReader in silverlight <test /> type tag problem

Hi I am parsing XML in silverlight, in my XML I have one tag is like <test attribute1="123" /> <test1 attribute2="345">abc text</test1> I am using XMLReader to parse xml like using (XmlReader reader = XmlReader.Create(new StringReader(xmlString))) { // Parse the file and display each of the nodes. while (reader.R...

Copying an xml file with inserting new elements in a specific location- C#

Hi I want to copy an xml file and insert in a specific element locaiton some more elements; What is the best and easiest way doing this. I can use xmlReader read elements and write one by one referring to each and every type- I had some issues with this but besides this seems to me too mush work that can be done somehow better. in the ex...