Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2006

Tip: Looking for answers? Try searching our database.

How can I validate an XML document with C#?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doru Roman - 29 Mar 2006 17:27 GMT
Hi,

I am a beginner and I try to understand how can I use C# and Netframework to
validate an XML document. Is XSD a solution? How?

Thanks,
Doru
Martin Honnen - 29 Mar 2006 17:41 GMT
> I am a beginner and I try to understand how can I use C# and Netframework to
> validate an XML document. Is XSD a solution? How?

The .NET framework supports validation against a DTD or against an XDR
schema (deprecated) or against W3C XSD schema(s).
With .NET 1.x you would use XmlValidatingReader to do the validation,
with .NET 2.0 you would create an XmlReader with the proper
XmlReaderSettings for the validation you want.
See
<http://samples.gotdotnet.com/quickstart/howto/doc/Xml/ValidationReadingXML.aspx>
for .NET 1.x and
<http://www.asp.net/quickstart/howto/doc/Xml/ValidationReadingXML.aspx>
for .NET 2.0.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Doru Roman - 29 Mar 2006 19:19 GMT
Thank you Martin. I will give it a try and eventually with more questions if
needed.

>> I am a beginner and I try to understand how can I use C# and Netframework
>> to validate an XML document. Is XSD a solution? How?
[quoted text clipped - 9 lines]
> <http://www.asp.net/quickstart/howto/doc/Xml/ValidationReadingXML.aspx>
> for .NET 2.0.
Doru Roman - 29 Mar 2006 20:46 GMT
In fact I have some questions as I got stuck.
I have an XML document. What is next? How do I bring the XML document into
my C# project so that I can create an XSD schema? Can I create a schema from
the XML menu Item?
Afterwards I will try to write the code to validate the document, but I need
help to get to this point.

> Thank you Martin. I will give it a try and eventually with more questions
> if needed.
[quoted text clipped - 12 lines]
>> <http://www.asp.net/quickstart/howto/doc/Xml/ValidationReadingXML.aspx>
>> for .NET 2.0.
Cerebrus - 29 Mar 2006 22:02 GMT
Hi Doru Roman,

>> I have an XML document. What is next? How do I bring the XML document into
>> my C# project so that I can create an XSD schema?

In Solution Explorer, right click the project name and then choose Add
-> Add Existing item... then select your XML file.

2. To create your XML Schema :

a) Manually method : In Solution Explorer, right click the project name
and then choose Add -> Add New item... then select "XML Schema"
b) Automatic method : Once your XML file is opened, open the XML menu
at the top, and choose "Create schema".

>> Can I create a schema from the XML menu Item?

Yes, that method is mentioned in point b) above.

Hope this helps,

Regards,

Cerebrus.
Doru Roman - 29 Mar 2006 23:29 GMT
Thanks

> Hi Doru Roman,
>
[quoted text clipped - 21 lines]
>
> Cerebrus.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.