You need to sign in to do that
Don't have an account?
Dinesh Khandelwal
Building a XML based on Schema
Hi all, I want to generate a XML based on Schema, which is available as a string input.
Sample schema is as below but it will not be fixed always,
How can i generate the XML which should look like below
and the values will be fetched from order custom object.
The main problem is to build the XML.. any idea how can we achieve this.
Thanks
dinesh
Sample schema is as below but it will not be fixed always,
<?xml version="1.0" standalone="yes"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="INPUT_MAIN" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="INPUT_MAIN"> <xs:complexType> <xs:sequence> <xs:element name="PROCESS_ID" type="xs:int" /> <xs:element name="ORDER_ID" type="xs:int" /> <xs:element name="ORDER_NO" type="xs:string" minOccurs="0" /> <xs:element name="ORDER_DESCRIPTION" type="xs:string" minOccurs="0" /> <xs:element name="ORDER_SHORT_DESCRIPTION" type="xs:string" minOccurs="0" /> <xs:element name="REMARKS" type="xs:string" minOccurs="0" /> <xs:element name="START_DATE" type="xs:string" minOccurs="0" /> <xs:element name="END_DATE" type="xs:string" minOccurs="0" /> <xs:element name="CUSTOMER" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:unique name="Constraint1" msdata:PrimaryKey="true"> <xs:selector xpath=".//INPUT_MAIN" /> <xs:field xpath="PROCESS_ID" /> </xs:unique> </xs:element> </xs:schema>
How can i generate the XML which should look like below
<?xml version="1.0" encoding="UTF-8"?> <NewDataSet> <INPUT_MAIN> <PROCESS_ID>9</PROCESS_ID> <ORDER_ID>9</ORDER_ID> <ORDER_NO>test string</ORDER_NO> <ORDER_DESCRIPTION>test string</ORDER_DESCRIPTION> <ORDER_SHORT_DESCRIPTION>test string</ORDER_SHORT_DESCRIPTION> <REMARKS>test string</REMARKS> <START_DATE>test string</START_DATE> <END_DATE>test string</END_DATE> <CUSTOMER>test string</CUSTOMER> </INPUT_MAIN> </NewDataSet>
and the values will be fetched from order custom object.
The main problem is to build the XML.. any idea how can we achieve this.
Thanks
dinesh
Also there is a similar question posted on this forum, check out the answer (https://developer.salesforce.com/forums?id=906F00000008ybEIAQ) which uses the above class.
So, is there any way to generate an XML based on schema as we have in Java.