473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

XmlReader, no ReadToEnd

Is there a way to avoid

With an object of type XmlReader is it possible to avoid

while (reader.Read())
{
//
}

i.e. read the Xml Document all in one go?
Jun 21 '06 #1
3 6212
You can use ReadInnerXml() and ReadOuterXml() to read the contents of
the context node as a string; if you call this at the top of the doc
then you will get everything...

Alternatively, if you want to fill an XmlDocument, you can use
Load(reader) on the XmlDocument.

Either way, it does ather make using XmlReader rather pointless,
however...

If you just want to read past the data (without returning it), then use
Skip() on the reader

Was it something specific you were trying to do? (there may be better
ways)

Marc

Jun 21 '06 #2
* Marc Gravell wrote:
You can use ReadInnerXml() and ReadOuterXml() to read the contents of
the context node as a string; if you call this at the top of the doc
then you will get everything...

Alternatively, if you want to fill an XmlDocument, you can use
Load(reader) on the XmlDocument.

Either way, it does ather make using XmlReader rather pointless,
however...

If you just want to read past the data (without returning it), then use
Skip() on the reader

Was it something specific you were trying to do? (there may be better
ways)

Marc


I want to read the XML in a ValidateXml function, because I have a
ValidateEventHandler that will run in the event of a problem with the
XML compared to its schema. So I just want the quickest way of reading
through my XmlReader.
Jun 21 '06 #3
Personally, I'd give Skip() a try... I haven't tested, but I believe
that internaly this does pretty much what you want. You would need to
test it with some deliberately malformed xml, of course.

Marc

Jun 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: xmlguy | last post by:
I believe this should be pretty elementary, but for some reason I cannot seem to think of how to write the an XML file from an incoming XML file. Basically this is what I do: Input: ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
0
by: Matthew Heironimus | last post by:
According to the XML 1.0 (Third Edition) W3C Recommendation (http://www.w3.org/TR/2004/REC-xml-20040204/#sec-line-ends) all #xD, #xA, and #xD#xA character combinations should be converted to a...
1
by: Matthew Heironimus | last post by:
According to the XML 1.0 (Third Edition) W3C Recommendation (http://www.w3.org/TR/2004/REC-xml-20040204/#sec-line-ends) all #xD, #xA, and #xD#xA character combinations should be converted to a single...
1
by: SamIAm | last post by:
Is there a way to do this without looping through all the nodes using read() I need to return the contents of the reader as a string Thanks S
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
0
by: Jen | last post by:
My main question: "How can I get a TextReader or Stream object from an existing XmlReader?". Read on for more: I have an existing XmlReader. Let's call it reader1. I'm creating another reader,...
2
by: jonfroehlich | last post by:
According to the MSDN documentation within the XmlTextReader class for ..NET 2.0, the recommended practice to create XmlReader instances is using the XmlReaderSettings class and the...
5
by: heday60 | last post by:
I've got this application that watches a directory for XML's and then parses them into a DB. It then moves them based on if the XML was succesful or a bad XML... foreach(FileInfo file in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.