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
11
votes
1 answer

Is it possible to save the current XMLReader Position for later use?

I have created an XMLReader object out of a Stream object which I was written to earlier by XMLWriter object. I know XMLReader object is forward only and therefore I want to be able to save current reading position, so I will be able to continue…
JavaSa
  • 5,813
  • 16
  • 71
  • 121
11
votes
3 answers

How can I clone MemoryStream object?

I have a MemoryStream object which is passed by Stream type parameter (Stream is abstract class in C#). I want to clone it to create another separate MemoryStream object with current position of the original and to create also a new XMLReader out of…
JavaSa
  • 5,813
  • 16
  • 71
  • 121
10
votes
4 answers

Why is FileStream not closed by XmlReader

So I am using the FileStream inside XmlReader using (XmlReader reader = XmlReader.Create(new FileStream(archivePath, FileMode.Open), readerSettings)) { reader.close() } However, the file feed into the XmlReader is still in the lock state after…
TOMMY WANG
  • 1,382
  • 3
  • 16
  • 39
10
votes
2 answers

How to read an xml file directly to get an XElement value?

Right now I am using: XElement xe = XElement.ReadFrom which requires an XmlReader: XmlReader reader = XmlTextReader.Create which requires a string, and that requires me to pass a StringReader: new StringReader which requires a…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
10
votes
3 answers

Performance: XmlReader or LINQ to XML

I have a 150 MB XML file which is used as DB in my project. Currently I'm using XmlReader to read content from it. I want to know if it is better to use XmlReader or LINQ to XML for this scenario. Note that I'm searching for an item in this XML and…
Nasser Hadjloo
  • 12,312
  • 15
  • 69
  • 100
10
votes
4 answers

How to get value from a specific child element in XML using XmlReader?

Here's the XML string. Question 1? abcdefg 123
woodykiddy
  • 6,074
  • 16
  • 59
  • 100
10
votes
2 answers

System.Xml.XmlException: Unexpected end of file while parsing Name has occurred

I'm using an XmlReader retrieved using SqlCommand.ExecuteXmlReader. Here is my input When I run this line of code: XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree()); it works the first time, reading in the first Product node as…
Codeman
  • 12,157
  • 10
  • 53
  • 91
10
votes
3 answers

porting to Android: why am I getting "Can't create default XMLReader; is system property org.xml.sax.driver set?"?

I am porting some Java code that worked fine on my desktop to Android. I have the following code segment: import org.xml.sax.InputSource; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; // ... XMLReader p =…
I Z
  • 5,719
  • 19
  • 53
  • 100
9
votes
2 answers

Prevent XmlTextReader from expanding entities

I am trying to read a XML document without expanding the entities, do some manipulations to it, and re-save it with the unexpanded entities as they were initially. When using the XDocument directly, it fails to load, throwing an exception tell me it…
decasteljau
  • 7,655
  • 10
  • 41
  • 58
9
votes
5 answers

Appending an existing XML file with XmlWriter

I've used the following code to create an XML file: XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter =…
user3105160
  • 307
  • 1
  • 4
  • 13
9
votes
3 answers

PHP open gzipped XML

I am struggling to read gzipped xml files in php. I did succeed in reading normal xml files, using XMLReader() like this: $xml = new XMLReader(); $xml->open($linkToXmlFile); However, this does not work when the xml file is gzipped. How can I unzip…
Fortega
  • 19,463
  • 14
  • 75
  • 113
8
votes
1 answer

XmlReader - problem reading xml file with no newlines

When I use XmlReader to parse an XML file, I get different results depending on whether the XML file is properly formatted (i.e. with newlines) or not. This is the code I'm using: XmlReader reader = new…
rabin
  • 369
  • 5
  • 15
8
votes
2 answers

How to best detect encoding in XML file?

To load XML files with arbitrary encoding I have the following code: Encoding encoding; using (var reader = new XmlTextReader(filepath)) { reader.MoveToContent(); encoding = reader.Encoding; } var settings = new XmlReaderSettings {…
Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
8
votes
1 answer

Read XElement from XmlReader

I'm playing around with parsing an XMPP XML stream. The tricky thing about the XML stream is that the start tag does not get closed until the end of the session, i.e. a complete DOM is never received.
sipsorcery
  • 30,273
  • 24
  • 104
  • 155
8
votes
1 answer

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 StreamRootChildDoc(string…
hIpPy
  • 4,649
  • 6
  • 51
  • 65
1 2
3
74 75