1
Is there a way to increment an item - XML to CSV?
Question asked by Jeff Nixon - 8/19/2019 at 4:17 PM
Answered
I have several items per XML that can have multiple child elements. So one header element and variable items of child elements. I need to assigned a sequential number to each child item (starting at 1). I assume there to be some kind of loop that can increment on each pass, but I can't work it out at all

Example:

    <xs:element name="Envelope">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Shipment">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Header" type="xs:string" />
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="ListItem" type="xs:string" />
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element name="ListItemDetail" type="xs:string" />
                                                </xs:sequence>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
Has anyone encountered this? So as per above, I get the Shipment once per xml, but I get ListItem many times. I need to assign a sequential number to this for each pass in the CSV output.


1 Reply

Reply to Thread
0
Liquid Support Replied
Employee Post Marked As Answer
Hi,

You should be able to connect the 'ListItem' node to a 'Position'' component, this will give you an additional node called 'Index' which is a 0 based index. You can then connect an Add component to get it to be 1 based index.

Here I used a sample schema ContactDetails, but it should be the same for your schema.
 

Reply to Thread