<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Read xml file content into an Attribute: How to? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351658#M236330</link>
    <description>&lt;P&gt;Thanks for the insight Mr &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/11191"&gt;@araujo&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I would like to tell you i have thousands of that XML files. Please is there any better way of doing it.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Sep 2022 21:44:38 GMT</pubDate>
    <dc:creator>rafy</dc:creator>
    <dc:date>2022-09-06T21:44:38Z</dc:date>
    <item>
      <title>Read xml file content into an Attribute: How to?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351650#M236324</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please i need your kind help.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SCENERIO&lt;/STRONG&gt;: INSERT CONTENT OF AN XML FILE AS A FIELD INTO A DATABASE&lt;/P&gt;
&lt;P&gt;- I am trying to read the content of an xml file into a flowfile attribute&lt;/P&gt;
&lt;P&gt;- I want to use the attribute as variable in sql query statement to insert the content into a DB&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ISSUES&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;- I tried to use both Xpath &amp;amp; Xquery but no success.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DATA: &lt;/STRONG&gt;The data i am trying to convert is as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version='1.0' encoding='utf-8'?&amp;gt;
&amp;lt;!DOCTYPE database&amp;gt;
&amp;lt;database xmlns='http://www.lotus.com/dxl' version='9.0' maintenanceversion='1.0'
 replicaid='8525886700702AFD' path='BStravel2.nsf' title='BSTravel_Expenses_and_Vacations'
 maintainunread='false' optimizetablebitmaps='true' increasemaxfields='true'
 compressdesign='true' compressdata='true' markmodifiedunread='false' logtransactions='false'
 uselz1='true'&amp;gt;
&amp;lt;databaseinfo dbid='85256700702AFD' odsversion='43' diskspace='261440'
 percentused='96.2421875' numberofdocuments='13'&amp;gt;&amp;lt;datamodified&amp;gt;&amp;lt;datetime
 dst='true'&amp;gt;20220813253,61-04&amp;lt;/datetime&amp;gt;&amp;lt;/datamodified&amp;gt;&amp;lt;designmodified
&amp;gt;&amp;lt;datetime dst='true'&amp;gt;2022062936,80-04&amp;lt;/datetime&amp;gt;&amp;lt;/designmodified&amp;gt;&amp;lt;/databaseinfo&amp;gt;
&amp;lt;launchsettings&amp;gt;&amp;lt;noteslaunch whenopened='openframeset' frameset='Launch' showaboutdocument='never'/&amp;gt;&amp;lt;/launchsettings&amp;gt;&amp;lt;/database&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for all your help .&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 04:46:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351650#M236324</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2022-09-08T04:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Read xml file content into an Attribute: How to?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351657#M236329</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95347"&gt;@rafy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You shouldn't need to extract the content as an attribute. Instead, use ReplaceText to replace the contents of the flowfile with the SQL template, like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;INSERT INTO my_table (xml_col) VALUES ('$1')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where $1 is a reference to the default regex capture group that captures the entire content.&lt;/P&gt;&lt;P&gt;In reality, it requires a bit more labour, since you have to escape the single quotes in the XML first.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;André&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 21:23:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351657#M236329</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-09-06T21:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Read xml file content into an Attribute: How to?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351658#M236330</link>
      <description>&lt;P&gt;Thanks for the insight Mr &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/11191"&gt;@araujo&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I would like to tell you i have thousands of that XML files. Please is there any better way of doing it.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 21:44:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351658#M236330</guid>
      <dc:creator>rafy</dc:creator>
      <dc:date>2022-09-06T21:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read xml file content into an Attribute: How to?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351659#M236331</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95347"&gt;@rafy&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same approach. Just create the processor(s) and let the files flow through it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;André&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 22:24:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Read-xml-file-content-into-an-Attribute-How-to/m-p/351659#M236331</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-09-06T22:24:04Z</dc:date>
    </item>
  </channel>
</rss>

