Objective:
Read complex xml file, do some minor transformations, then load into existing mongodb collection.
Current Approach:
Use tInputFileMSXML to flatten xml into multiple tHashOutputs (works fine), use tMap to do transformations and joining (works fine), construct output to load into Mongodb (here is the problem).
Challenge (I think):
I tried using the tWriteJsonField, but it does not support multiple loop elements. How can I get the data into the structure needed to insert into MongoDB? I did search the forum (found that multiple loop elements are not support in Json related talend components), and reviewed every tutorial I could find on the internet, but none have complex XML examples.
Any help would be appreciated.
XML Source (pseudo example):
<Product name="Domesticated Animal Care Manuals">
<Attributes>
<Attrib name="Category">Care Manuals</Attrib>
<Attrib name="Type">Domesticated Animals</Attrib>
</Attributes>
<Images>
<Image name="bird photo">x2345.jpg</Image>
<Image name="cat photo">x45678.jpg</Image>
<Image name="dog photo">x5927.jpg</Image>
</Images>
<productPdfs>
<Document name="Bird Care Manual">takecareofyourbird.pdf</Document>
<Document name="Cat Care Manual">takecareofyourcat.pdf</Document>
<Document name="Dog Care Manual">takecareofyourdog.pdf</Document>
</productPdfs>
<productPricing>
<COG Type="EACH">
<Attrib name="Our Cost">4</Attribute>
<Attrib name="Retail Price">15.5</Attribute>
<Attrib name="Sale Price">10</Attribute>
</COG>
</productPricing>
</Product>
Desired Output
Mongodb Collection Structure:
{"name":"Domesticated Animal Care Manuals","category":"Care Manuals","type":"Domesticated Animals","images":,"productPdfs":,"productPricing":}