I have to send data to some external service in xml format.
They have provided xml schema as below,
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.
w3.org/2001/XMLSchema">
<xs:element name="TRANSACTION">
<xs:complexType>
<xs:sequence>
<xs:element name="LOGIN">
<xs:complexType>
<xs:sequence>
<xs:element name="USERID" type="xs:string" />
<xs:element name="PASSWORD" type="xs:string" />
<xs:element name="TRANID" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CUSTOMER">
<xs:complexType>
<xs:sequence>
<xs:element name="CUSTSSN" type="xs:unsignedInt" />
<xs:element name="CUSTFNAME" type="xs:string" />
<xs:element name="CUSTLNAME" type="xs:string" />
<xs:element name="CUSTADDRESS" type="xs:string" />
<xs:element name="CUSTCITY" type="xs:string" />
<xs:element name="CUSTSTATE" type="xs:string" />
<xs:element name="CUSTZIP" type="xs:unsignedShort" />
<xs:element name="CUSTHOMEPHONE" type="xs:unsignedInt" />
<xs:element name="CUSTMOBILEPHONE" type="xs:unsignedInt" />
<xs:element name="CUSTEMAIL" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:element>
</xs:schema>
Based on above schema, how should I write my xml?
In general XSD describes a set of documents which are conformant with a schema. For most schemas there are many different documents which are valid against the schema. In your case the schema prescribes everything expect the content of the strings, so something like:
would do – you should be able to fill in the bits I have left out