Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using XSD to validate XML

Status
Not open for further replies.

lfc77

Programmer
Joined
Aug 12, 2003
Messages
218
Location
GB
I have an xml doucument that I want to validate with a XSD schema. I'm new to this and I don't know exactly how I make the references at the top of the documents so that the XSD file will validate the XML file in my C# program. My code is below :

change.xml :

<?xml version=&quot;1.0&quot;?>
<rsp-vcn xmlns:xsi=&quot; xsi:noNamespaceSchemaLocation=&quot;change.xsd&quot;
message_id=&quot;0&quot;>
<auth>
<cug>5745</cug>
<pasw>Password1</pasw>
</auth>
<service type=&quot;change&quot;>
<info>
<number>441173060201</number>
<subcug>1234</subcug>
<pay>card</pay>
<currency>usd</currency>
<language>eng</language>
<cash>20.00</cash>
</info>
</service>
</rsp-vcn>


change.xsd :

<?xml version=&quot;1.0&quot; ?>
<xs:schema xmlns:xs=&quot; <xs:element name=&quot;rsp-vcn&quot;>
<xs:complexType>
<xs:sequence>
<xs:element name=&quot;auth&quot;>
<xs:complexType>
<xs:sequence>
<xs:element name=&quot;cug&quot; type=&quot;xs:string&quot; />
<xs:element name=&quot;pasw&quot; type=&quot;xs:string&quot; />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name=&quot;service&quot;>
<xs:complexType>
<xs:sequence>
<xs:element name=&quot;info&quot; maxOccurs=&quot;unbounded&quot;>
<xs:complexType>
<xs:sequence>
<xs:element name=&quot;number&quot; type=&quot;xs:string&quot; minOccurs=&quot;1&quot; />
<xs:element name=&quot;subcug&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; />
<xs:element name=&quot;pay&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; />
<xs:element name=&quot;currency&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; />
<xs:element name=&quot;language&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; />
<xs:element name=&quot;cash&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name=&quot;type&quot; use=&quot;required&quot;>
<xs:simpleType>
<xs:restriction base=&quot;string&quot;>
<xs:enumeration value=&quot;change&quot; />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name=&quot;message_id&quot; type=&quot;xs:string&quot; use=&quot;required&quot; />
</xs:complexType>
</xs:element>
</xs:schema>


Any help would be really appreciated.


Cheers,

lfc77
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top