XML Import error

1
Hi, I have created an app for importing XML documents in Mendix. It is working fine but it is importing only one data from the list which is the last record of the list. I have followed https://docs.mendix.com/howto/integration/importing-xml-documents/ The XML file used is https://docs.mendix.com/attachments/howto/integration/importing-xml-documents/18581651.xml → Import mapping I have used is → Microflow used   Please suggest me the solution that I can import all the record of the list. Thanks and Regards, Harshraj Singh  
asked
2 answers
1

You did nothing wrong, there is an error in the xml schema provided in that tutorial.

The schema should be:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name='Customers'>
    <xs:complexType>
      <xs:sequence>
        <xs:element name='Customer' maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
				<xs:element name='ID' type='xs:string'/>
				<xs:element name='CompanyName' minOccurs='0' type='xs:string'/>
				<xs:element name='ContactName' minOccurs='0' type='xs:string'/>
				<xs:element name='ContactTitle' minOccurs='0' type='xs:string'/>
				<xs:element name='Phone' minOccurs='0' type='xs:string'/>
				<xs:element name='Fax' minOccurs='0' type='xs:string'/>
				<xs:element name='Address' minOccurs='0' type='xs:string'/>
				<xs:element name='City' minOccurs='0' type='xs:string'/>
				<xs:element name='Region' minOccurs='0' type='xs:string'/>
				<xs:element name='PostalCode' minOccurs='0' type='xs:string' />
				<xs:element name='Country' minOccurs='0' type='xs:string'/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

This maxOccurs makes sure Mendix understands there will be multiple clients in the xml.

To make it wor in Mendix: reimport the xsd and recreate the import mapping.

I hope this helps.

answered
0

Hi Harshaj,

Have you tried changing the “Method” to “Create an object”? Does it now still import only one record?

If not, the ids of the incoming customer objects are likely to be the same, so each customer overwrites the previous.

answered