Solved

XmlElement to XmlReader?

Posted on 2011-09-28
3
3,460 Views
Last Modified: 2012-05-12
I need to figure out how to convert an XmlNode or XmlElement object into a stream so XmlReader can read it and validate against a schema. I can easily get the XmlReader to read from a file but I need it to read from an XmlElement in memory. Please help!
0
Comment
Question by:Russ Suter
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 36720333
How about something like this?
XmlDocument x = new XmlDocument();
XmlNode xel;

x.Load("input.xml");
xel = x.SelectSingleNode("//StudentName");

System.IO.StringReader reader = new System.IO.StringReader(xel.OuterXml);

XmlReader xReader = XmlReader.Create(reader);

Open in new window

0
 
LVL 20

Author Closing Comment

by:Russ Suter
ID: 36720385
I never thought to use StringReader instead of StreamReader. Sometimes you can't see the forest for the trees eh? That worked a treat. Thanks!
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 36772074
NP. Glad to help  = )
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now