473,395 Members | 1,554 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,395 software developers and data experts.

Converting from XmlDocument to XmlReader

I need to write a method that takes System.Xml.XmlDocument and Xsd Path
to validate XmlDocument.
How can I convert XmlDocument to XmlReader?

Nov 12 '05 #1
1 43711
Bostonasian wrote:
I need to write a method that takes System.Xml.XmlDocument and Xsd Path
to validate XmlDocument.
How can I convert XmlDocument to XmlReader?


[.NET 1.X]
Efficient way is to use XmlNodeReader, but that won't help with
validation. For validation you need XmlTextReader, so usual way of doing
it (not really efficient, but working one) is

XmlTextReader r = new XmlTextReader(new StringReader(xmlDoc.OuterXml));
XmlvalidatingReader vr = new XmlValidatingReader(r);
....

[.NET 2.0]
In .NET 2.0 XmlDocument has Validate() method.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #2

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

Similar topics

1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
4
by: David Thielen | last post by:
Hi; I have nodes in the XmlDocument I create that need to be written exactly as is - not converting < to %lt; and no changing the whitespace. (This is for the SpreadsheetML schema and it reads...
8
by: Charles.Deisler | last post by:
Im currently using the following code.. XmlDocument xmlData = new XmlDocument(); XmlTextWriter xmlwriter = new XmlTextWriter(Response.OutputStream,System.Text.Encoding.UTF8); XmlReader...
2
by: muesliflakes | last post by:
I wish to receive some data from SqlServer as XML and write out result to as a string. Eg: cmd = new SqlCommand( "select * from blah for xml auto", con ); XmlReader result =...
10
by: Thirsty Traveler | last post by:
All of the XmlReader examples assume that the XmlDocument is being read from a file. However, I would like to use it with an XmlDocument passed as a method parameter, but am not sure how. Any...
2
by: raj | last post by:
i have this code which is upgraded to work with 2.0 and works great with framework 1.0 and 1.1 without the upgraded code. //2.0 code// public static XmlReader RtfToXml( string Rtf ) { if (...
4
by: Paul | last post by:
The title says it all. Is there a speed efficient way of validating that a string contains valid Xml without the overhead of try catch around a load attempt? Thanks in advance.
1
by: engwar | last post by:
The title says it all. How do I use XMLDocument.Validate() against a DTD. In all my Googling about this I only find examples of how to validate an XMLReader or XmlValidatingReader against a DTD....
2
by: SammyBar | last post by:
Hi all, I'm trying to convert the xml obtained from a XmlReader object into a UTF-8 array. My general idea is to read the XmlReader and write into a MemoryStream. Then convert the MemoryStream...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.