XML mapping

Hi! I need to import XML and followed the example from the documentation. While the example works perfectly fine, I am having troubles with the my XML. The data I am interested in are the <attribute> elements (createdby, name, id,...)   <list count="1" limit="1" type="solution" url="https://www.example.com/api/Solution/list"> <resource id="5ce5cf9f" type="Solution"> <attributes> <attribute name="confProdRequiresApproval" value="false"/> <attribute name="id" value="0068"/> <attribute name="name" value="12345 - XXX abc yyy "/> </attributes> </resource> </list>   I created the XSD file (automatically):   <?xml version="1.0" encoding="UTF-8"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="list" type="listType"/> <xs:complexType name="attributeType"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:string" name="name" use="optional"/> <xs:attribute type="xs:string" name="value" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="attributesType"> <xs:sequence> <xs:element type="attributeType" name="attribute" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="resourceType"> <xs:sequence> <xs:element type="attributesType" name="attributes"/> </xs:sequence> <xs:attribute type="xs:string" name="id"/> <xs:attribute type="xs:string" name="url"/> <xs:attribute type="xs:string" name="type"/> </xs:complexType> <xs:complexType name="listType"> <xs:sequence> <xs:element type="resourceType" name="resource"/> </xs:sequence> <xs:attribute type="xs:string" name="count"/> <xs:attribute type="xs:string" name="limit"/> <xs:attribute type="xs:string" name="type"/> </xs:complexType> </xs:schema>   So, the information about the “attributes” is gone and the mapping of the individual XML attributes with the attributes is not possible:   Is there a way to solve this problem and import the XML?
1 answers

Hi Erwin,

It looks like your XML is of the kind ‘name-value pairs’. This means that all your attributes will be imported as a list of attributes under your list attribute.

What you should do is

  1. Import the data using this mapping.
  2. Retrieve the attributes from the list.
  3. Then loop over this list of attributes, and map them to the values you know.

It will look something like this:

if name = confProdRequiresApproval then change confProdRequiresApproval in Mendix with the value from that object.

Do this for every element known attribute in your list and you are done.