Questions tagged [xmlreader]

xmlreader - Represents a reader that provides fast, noncached, forward-only access to XML data.

Represents a reader that provides fast, noncached, forward-only access to XML data.

More

1120 questions
103
votes
7 answers

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.
Gloria Huang
  • 1,043
  • 2
  • 8
  • 4
87
votes
7 answers

How to use XMLReader in PHP?

I have the following XML file, the file is rather large and i haven't been able to get simplexml to open and read the file so i'm trying XMLReader with no success in php
Shadi Almosri
  • 11,678
  • 16
  • 58
  • 80
72
votes
5 answers

Deciding on when to use XmlDocument vs XmlReader

I'm optimizing a custom object -> XML serialization utility, and it's all done and working and that's not the issue. It worked by loading a file into an XmlDocument object, then recursively going through all the child nodes. I figured that perhaps…
PhilChuang
  • 2,556
  • 1
  • 23
  • 29
66
votes
5 answers

What is the best way to parse (big) XML in C# Code?

I'm writing a GIS client tool in C# to retrieve "features" in a GML-based XML schema (sample below) from a server. Extracts are limited to 100,000 features. I guestimate that the largest extract.xml might get up around 150 megabytes, so obviously…
corlettk
  • 13,288
  • 7
  • 38
  • 52
58
votes
4 answers

DTD prohibited in xml document exception

I'm getting this error when trying to parse through an XML document in a C# application: "For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the…
ConnorU
  • 1,379
  • 2
  • 15
  • 27
55
votes
4 answers

There is no Unicode byte order mark. Cannot switch to Unicode

I am writing an XML validator with XSD. Below is what I did, but when the validator reached the line while (list.Read()) it gives me the error There is no Unicode byte order mark. Cannot switch to Unicode. Can anybody help me fix it? public class…
user3122648
  • 887
  • 2
  • 8
  • 21
38
votes
1 answer

Tell StructureMap to use a specific constructor

I have two services that require an XPathDocument. I want to be able to define named instances of XPathDocumnet to use in the configuration of the two services. I also want to be able to tell StuctureMap which constructor of XPathDocument to use.…
awilinsk
  • 2,054
  • 6
  • 31
  • 50
37
votes
1 answer

XmlReader - Self-closing element does not fire a EndElement event?

I am using XmlReader in .NET to parse an XML file using a loop: while (xml.Read()) { switch xml.NodeType { case XmlNodeType.Element: //Do something case XmlNodeType.Text: //Do something case XmlNodeType.EndElement: …
Vincent
  • 22,366
  • 18
  • 58
  • 61
32
votes
5 answers

Why "Data at the root level is invalid. Line 1, position 1." for XML Document?

I am using a third-party DLL which transmits an XML document over the internet. Why would the DLL be throwing the following exception? Data at the root level is invalid. Line 1, position 1. (see below for full exception text.) Here are the first…
CJ7
  • 22,579
  • 65
  • 193
  • 321
28
votes
6 answers

getting the current position from an XmlReader

Is there a way to get the current position in the stream of the node under examination by the XmlReader? I'd like to use the XmlReader to parse a document and save the position of certain elements so that I can seek to them later. Addendum: I'm…
dmo
  • 3,993
  • 6
  • 35
  • 39
26
votes
2 answers

Current line number from a System.Xml.XmlReader (C# & .Net)

Does anyone know how I can get the current line number of an System.Xml.XmlReader? I am trying to record where in a file I find Xml elements.
Danielb
  • 1,608
  • 5
  • 24
  • 34
24
votes
2 answers

Reading attribute values with XmlReader

I have an XML file that I'm trying to read from here, and have the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.IO; namespace XML { class Program { …
weskpga
  • 2,017
  • 7
  • 29
  • 43
22
votes
2 answers

From XmlDocument To XmlReader .Net

After an advice from a user that answered to my question I'm tring to convert my XmlDocument code to XmlReader code but I'm having some troubles. This is XML (generated from php-mysql Page)…
user1107078
  • 455
  • 1
  • 7
  • 18
18
votes
2 answers

"The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared."

Sometimes, when validating certain XML documents using an XmlValidatingReader, I receive the following error: System.Xml.Schema.XmlSchemaValidationException: "The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared." The same…
roufamatic
  • 18,187
  • 7
  • 57
  • 86
17
votes
6 answers

Parsing an XML stream with no root element

I need to parse a continuous stream of well-formed XML elements, to which I am only given an already constructed java.io.Reader object. These elements are not enclosed in a root element, nor are they prepended with an XML header like
PNS
  • 19,295
  • 32
  • 96
  • 143
1
2 3
74 75