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

XmlResourceResolver

Hi all

I am using XmlValidatingReader to read XML one line at a time and also
validate it as I go along.

I cannot rely on the XML to have the required

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DataImport.xsd"

attributes in the root node, and I don't want to risk someone modifying my
XSD either. So what I want to do is to tell XmlValidatingReader to
validated against DataImport.XSD that I have added to my project with Build
Action = Content.

I've looked at a few examples, none of them do exactly what I need and to be
honest went over my head.

Does anyone have an example showing how to use an embedded XSD file with an
XmlValidatingReader please?

Thanks

Pete
Feb 13 '06 #1
1 1893
I worked out this code

XmlTextReader tr = new XmlTextReader("DataImport.xml");
XmlValidatingReader vr = new XmlValidatingReader(tr);
vr.ValidationType = ValidationType.Schema;
vr.ValidationEventHandler +=new
ValidationEventHandler(vr_ValidationEventHandler);

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream resourceStream =
a.GetManifestResourceStream("WindowsApplication9.D ataImport.xsd");
XmlReader xsdReader = new XmlTextReader(resourceStream);

vr.Schemas.Add(null, xsdReader);

while (vr.Read());
MessageBox.Show("Finished");
Feb 13 '06 #2

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

Similar topics

6
by: Bill Cohagan | last post by:
I've got a c# app that does some transforms using XSL files that are stored as Embedded Resources in the app. That turns out to be significant; i.e., the problem I've encountered goes away if I...
3
by: Nathan Alden | last post by:
Hi all. I have an XML schema that has a couple of <xs:import> tags that reference (using schemaLocation) schemas as embedded resources in a DLL. For example: <xs:import...
15
by: kurt sune | last post by:
Anybody has a tip of where to find info/example how to retrieve an icon from a .RESX-file? /k
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.