Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How extract attributes from XML and put into the postgreSQL using NiFi

How extract attributes from XML and put into the postgreSQL using NiFi

Explorer

Hello,

Below is the content of my XML file and I would like to extract attributes below and put it to the SQL table.

Block Id: 1201
Track_ID: 1

Kp_Began: 1020501

Kp_End: 1026951

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<GENERIC_SYSTEM_PARAMETERS Tool_Version="Chain1_V16.0.0.1" Sector_ID="" Writer_Name="" SyPD_Version="UEVOL-0248-AP" Checksum="4124281209139518616" XML_File_Version="AP_Plus_58" Date="2018-12-21" Comment="" xmlns:xsi="<a href="<a href="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>" target="_blank"><a href="http://www.w3.org/2001/XMLSchema-instance</a" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a</a>>" target="_blank"><a href="<a href="http://www.w3.org/2001/XMLSchema-instance</a" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a</a>" target="_blank"><a href="http://www.w3.org/2001/XMLSchema-instance</a</a" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a</a</a>>>" xsi:noNamespaceSchemaLocation="System_Data_Base_vAP_Plus_58.xsd">
<Blocks Last_SyDB_Version_ID_Memorized="" Data_Familly="DF4">
<Block ID="1201" Internal_Name="B_SDDB_ZD_27_25_PT_W1793_ZD" Name="B_1201">
<Track_ID>1</Track_ID>
<Secondary_Detection_Device_ID>1</Secondary_Detection_Device_ID>
<Point_ID>27</Point_ID>
<Kp_Begin>1020501</Kp_Begin>
<Kp_End>1026951</Kp_End>
<Next_Up_Normal_Block_ID>236</Next_Up_Normal_Block_ID>
<Next_Down_Normal_Block_ID>2033</Next_Down_Normal_Block_ID>
<Next_Down_Reverse_Block_ID_Not_Defined>0</Next_Down_Reverse_Block_ID_Not_Defined>
<Next_Up_Reverse_Block_ID_Not_Defined>0</Next_Up_Reverse_Block_ID_Not_Defined>
<Up_Buffer_Zone_Block_ID_List>
<Block_ID>236</Block_ID>
<Block_ID>5</Block_ID>
<Block_ID>6</Block_ID>
<Block_ID>7</Block_ID>
</Up_Buffer_Zone_Block_ID_List>
<Down_Buffer_Zone_Block_ID_List>
<Block_ID>2032</Block_ID>
<Block_ID>2033</Block_ID>
</Down_Buffer_Zone_Block_ID_List>
<Kp_Begin_Details Details_Value="1020501" Details_Corrected_Gap_Value="0" Details_Corrected_Trolley_Value="0"/>
<Kp_End_Details Details_Value="1026951" Details_Corrected_Gap_Value="0" Details_Corrected_Trolley_Value="0"/>
<Power_Supply>Non_Regenerative</Power_Supply>
<With_BSR>false</With_BSR>
<TD_Reversal_Up_Buffer_Zone_Block_ID_List>
<Block_ID_Not_Defined>0</Block_ID_Not_Defined>
</TD_Reversal_Up_Buffer_Zone_Block_ID_List>
<TD_Reversal_Down_Buffer_Zone_Block_ID_List>
<Block_ID_Not_Defined>0</Block_ID_Not_Defined>
</TD_Reversal_Down_Buffer_Zone_Block_ID_List>
<Block_Orientation>Both</Block_Orientation>
</Block>

 

 

 

As I understand I have to use GetFile>SplitXML>EvaluateXpath>putSQL Processor.

So, it will be highly appreciated if anyone can explain what will be the configuration in my NiFi flow to extract the attributes I needed from the XML?

Don't have an account?
Coming from Hortonworks? Activate your account here