List Info

Thread: Validating XML schema in C#




Validating XML schema in C#
user name
2006-11-04 19:11:35
Does this help?

http://www.codeproject.com/soap/Simple_XML_Validator.asp


or this?

http://www.codeguru.com/Csharp/Csharp/cs_dat
a/xml/article.php/c6737/


Peter

Ysgrifennodd R. Rogers:
> Hi,
>
> By calling Dataset.WriteXml, my code produces XML as
listed below.
>
> The user can also load the XML file, and I will use
Dataset.ReadXML to do
> this. Preferably before calling that method, I would
like to validate the
> schema of the XML to ensure that it has the same
structure as an XML file
> produced by WriteXml. How can I do that?
>
> At present, I am loading the XML file and writing code
like this:
>                         ValidXml =
>                                 (LoadedOk) &
>
>
(dsKeysAndValues.Tables[dsnKeysAndValues].Columns[KeyGroup]
!= null) &
>
>
(dsKeysAndValues.Tables[dsnKeysAndValues].Columns[ValueGroup
] != null) ;
> The code not only doesn't work, but it also doesn't
seem elegant - if the
> XML file is large, it will take time just to load the
file, before I can
> validate it.
> How can I validate the schema of XML to ensure that it
matches what I am
> expecting?
>
> Thanks for your help, pointers, and time!
>
> Richard
> The mystery is out there - in the XML-Files (X-files
music follows.)
>
> XML produced using WriteXml:
> <?xml version="1.0"
standalone="yes"?>
> <KeysAndValues>
>   <xs:schema id="KeysAndValues"
xmlns=""
> xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-comml-ms
data">
>     <xs:element name="KeysAndValues"
msdata:IsDataSet="true"
> msdata:Locale="en-CA">
>       <xs:complexType>
>         <xs:choice
maxOccurs="unbounded">
>           <xs:element
name="KeysAndValues">
>             <xs:complexType>
>               <xs:sequence>
>                 <xs:element name="Key"
minOccurs="0">
>                   <xs:simpleType>
>                     <xs:restriction
base="xs:string">
>                       <xs:maxLength
value="50" />
>                     </xs:restriction>
>                   </xs:simpleType>
>                 </xs:element>
>                 <xs:element name="Value"
minOccurs="0">
>                   <xs:simpleType>
>                     <xs:restriction
base="xs:string">
>                       <xs:maxLength
value="255" />
>                     </xs:restriction>
>                   </xs:simpleType>
>                 </xs:element>
>               </xs:sequence>
>             </xs:complexType>
>           </xs:element>
>         </xs:choice>
>       </xs:complexType>
>     </xs:element>
>   </xs:schema>
>   <KeysAndValues>
>     <Key>        K1</Key>
>     <Value>     V9999</Value>
>   </KeysAndValues>
>
> ===================================
> This list is hosted by DevelopMentorŪ  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com

>
>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Validating XML schema in C#
user name
2006-11-06 22:09:32
Hi Peter,

I will review those links thoroughly; they look very
promising!

Thanks a lot,

Richard
-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of Peter Bradley
Sent: November 4, 2006 2:12 PM
To: DOTNET-CLRDISCUSS.DEVELOP.COM
Subject: [Bulk] Re: [DOTNET-CLR] Validating XML schema in C#

Does this help?

http://www.codeproject.com/soap/Simple_XML_Validator.asp


or this?

http://www.codeguru.com/Csharp/Csharp/cs_dat
a/xml/article.php/c6737/


Peter

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )