1
XML to CSV
Question asked by Luke Petterson - 4/20/2018 at 12:08 PM
Answered
Hi,
 
im using the trial at the moment. I have a 1gb xml file that i need to MAP to .csv. I stumbled upon liquid after a google search.
 
The XML is split into all different elements that contains inventory data for different workstations on a network. Its look similair to this
 
<OS_Details>
  <Resourceid>
  <OperatingSystem>
  <Edition>
</OS_Details>
<TCP_IP>
  <ResourceID>
  <IP_Address>
  <Mac_Address>
</TCP_IP>
 
so resourceID is common element that represents all computers on the network. Resourceid is common between all the elements.
 
how can i get the output csv export to be
 
resourceID, Operating System, Ip address
1, windows 7, 192.168.1.2
2, windows 10, 192.168.2.4
 
How can i tell the mapper to say hey all resourceid elements are related to each other and contain the same data.
 
hoe that makes sense. Thanks in advance.

3 Replies

Reply to Thread
0
Liquid Support Replied
Employee Post Marked As Answer
Hi Luke
 
You need to use the Join component. I've mocked this up to demonstrate.
 
Sample Data
 
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Studio 2018 (https://www.liquid-technologies.com) -->
<RootElement>
    <TCP_IP>
        <ResourceID>1</ResourceID>
        <IP_Address>1.1.1.1</IP_Address>
        <Mac_Address>xxxx</Mac_Address>
    </TCP_IP>
    <TCP_IP>
        <ResourceID>1</ResourceID>
        <IP_Address>2.2.2.2</IP_Address>
        <Mac_Address>yyyy</Mac_Address>
    </TCP_IP>
    <TCP_IP>
        <ResourceID>2</ResourceID>
        <IP_Address>3.3.3.3</IP_Address>
        <Mac_Address>zzzz</Mac_Address>
    </TCP_IP>
    <OS_Details>
        <Resourceid>1</Resourceid>
        <OperatingSystem>Window</OperatingSystem>
        <Edition>10</Edition>
    </OS_Details>
    <OS_Details>
        <Resourceid>2</Resourceid>
        <OperatingSystem>Debian</OperatingSystem>
        <Edition>7</Edition>
    </OS_Details>
</RootElement>
Working through the new Data Mapper wizard, it will infer an XSD from the sample data, and you will need to define the structure of the CSV file as you work through the wizard.
 
You can then use the join component as shown. Basically for every 'Table A' it will find all the 'Table B' entries where the join values match.
 
 
The resulting CSV looks like this
 
1,Window,1.1.1.1
1,Window,2.2.2.2
2,Debian,3.3.3.3
 
NOTE: You would need to use the Concat function if you want to combine the OS and the edition into a single entry.
0
Luke Petterson Replied
Hi,
 
Thanks very much for this.
 
Can I only Join 2 Elements using Join?
 
I cant seem to add more as there are about 20 elements in my XML that I am testing with that all have resourceID.
 
Many thanks again for your help.
 
 
0
Liquid Support Replied
Employee Post
You would need to add a new Join component for each additional parameter and chain the Joins together.

Reply to Thread