Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 02-27-2018 02:40 PM
Hi everyone.
I have the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns:*** xmlns:xsi=*** xsi:schemaLocation=***>
<version>1.0</version>
<id>15</id>
<date>2018-01-01</date>
<sender>
<senderId>
<idType>G</idType>
<idCode>code</idCode>
</senderId>
<senderName>name</senderName>
</sender>
<paymentsNumber>2</paymentsNumber>
<paymentsTotal>800.40</paymentsTotal>
<payment>
<paymentId>1</paymentId>
<paymentAmount>400.20</paymentAmount>
<paymentResult>0</paymentResult>
<paymentDate>2018-02-01</paymentDate>
</payment>
<payment>
<paymentId>2</paymentId>
<paymentAmount>400.20</paymentAmount>
<paymentResult>0</paymentResult>
<paymentDate>2018-02-02</paymentDate>
</payment>
</flow>
I need to extract all tags values and to execute insert queries on different tables. In particular:
- <version>, <id>, <date>, <idType>, <idCode>, <senderName>, <paymentsNumber>, <paymentsTotal> need to be inserted in one table
- <version>, <id>, <date> and all tags values inside <payment> need to be inserted in another table (an insert query for every <payment> tag occurrence)
How can I achieve this result? I tried to use ReplaceText + PutSQL, but this combination seems to not be useful.
Any help will be appreciated!
Regards.
Created 02-27-2018 02:45 PM
Use TransformXML
Use SplitXML
or use EvaluateXPath or EvaluateXQuery
XSLT will work great.
https://www.linkedin.com/pulse/parsing-xml-logs-nifi-part-1-3-chris-gambino/
https://pierrevillard.com/2017/09/07/xml-data-processing-with-apache-nifi/
Created 02-27-2018 02:45 PM
Use TransformXML
Use SplitXML
or use EvaluateXPath or EvaluateXQuery
XSLT will work great.
https://www.linkedin.com/pulse/parsing-xml-logs-nifi-part-1-3-chris-gambino/
https://pierrevillard.com/2017/09/07/xml-data-processing-with-apache-nifi/
Created 03-01-2018 03:28 PM
Thank you @Timothy Spann, I combined TransformXML, SplitXML and EvaluateXPath, and I obtained the desired result.