maxbback / nifi-xml

Convert XML to csv with xml2csv processing with NiFi and Groovy
8 stars 3 forks source link

Creating Avro model problem against our XML product file? #1

Open MehmetAliArslanoglu opened 3 years ago

MehmetAliArslanoglu commented 3 years ago

Hi Max, I want to convert my XML into csv file. I am using your NiFi template. But after NiFi processed XML, it puts all records in one row. When i extract below xml parts from our xml file converter working properly.

<channel>
<title>MyTitle</title>
<link>https://www.myadress.com</link>
<description></description>
</channel>

How can i create proper model for our xml file? I couldn't figured out the way i correct my model for my XML. Regards, Mehmet Ali


My "AvroSchemaRegistry"'s model like below.


{
  "type": "record",
  "name": "rss",
  "namespace": "g",
  "fields" : [
    {"name": "id", "type": ["null", "string"]},
    {"name": "mobile_android_app_link", "type": ["null", "string"]},
    {"name": "title", "type": ["null", "string"]},
    {"name": "mobile_ios_app_store_id", "type": ["null", "string"]}
  ]
}

My original XML file's inner looks below like. It has multiple items in it.


<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>MyTitle</title>
<link>https://www.myadress.com</link>
<description></description>
<item>
<g:id>15644531</g:id>
<g:mobile_android_app_link>android-app://com.sfot.myaddress/myaddress/product/156TT531</g:mobile_android_app_link>
<title>Elizabeth Arden Kadın Fondoten Renkli Standart Beden</title>
<g:mobile_ios_app_store_id>5186TT790</g:mobile_ios_app_store_id>
</item>
<item>
<g:id>15644523</g:id>
<g:mobile_android_app_link>android-app://com.sfot.myaddress/myaddress/product/15tTT531</g:mobile_android_app_link>
<title>Elizabeth Arden  Renkli Standart Beden</title>
<g:mobile_ios_app_store_id>5186TT790</g:mobile_ios_app_store_id>
</item>
<item>
---
</item>
</channel>
</rss>
maxbback commented 3 years ago

Can you share your XSD as well? I will then be able to try your xml file out and see what the issue could be Interesting topic

MehmetAliArslanoglu commented 3 years ago

Hi Max,

I've uploaded my XSD file. Also i've uploaded small part of my full XML product file too.

Thnx for your reply too.

Regards.


products.zip

short_products_example.zip