<?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: Preserving the parent element in XML document with XMLReader in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349292#M235594</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98065"&gt;@ChuckE&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do your XML messages conform to defined a schema?&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;</description>
    <pubDate>Mon, 01 Aug 2022 21:57:26 GMT</pubDate>
    <dc:creator>araujo</dc:creator>
    <dc:date>2022-08-01T21:57:26Z</dc:date>
    <item>
      <title>Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349057#M235514</link>
      <description>&lt;P&gt;When using the XMLReader service, how do you retain the outermost parent element of an XML document so when I convert it to JSON I have the outermost element in the JSON version too?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, given the following XML document how do I capture the "&amp;lt;a&amp;gt;" element rather than just the "&amp;lt;b&amp;gt;" element?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;a&amp;gt;&lt;BR /&gt;  &amp;lt;b&amp;gt;45&amp;lt;/b&amp;gt;&lt;BR /&gt;&amp;lt;/a&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want:&lt;/P&gt;&lt;PRE&gt;{"a": {"b":45}}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I get:&lt;/P&gt;&lt;PRE&gt;{"b":45}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 06:13:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349057#M235514</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-07-29T06:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349104#M235523</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Im not sure this can be fixed by changing some configuration on what you have wither on the processor or the service level. Since the root element is not considered in the conversion from xml to Json, as workaround you can surround your xml with arbitrary root element with the ReplaceText Processor before the ConvertRecrod Processor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_0-1659116224899.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35073i3458F5B585328674/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_0-1659116224899.png" alt="SAMSAL_0-1659116224899.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp; Search Value: &lt;STRONG&gt;(?s)(^.*$)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp; Replacement Value: &lt;STRONG&gt;&amp;lt;root&amp;gt;$1&amp;lt;/root&amp;gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp; Evaluation Mode: &lt;STRONG&gt;Entire Text&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;This will output the following xml:&lt;/P&gt;&lt;PRE&gt;&amp;lt;root&amp;gt;n&amp;lt;a&amp;gt;
  &amp;lt;b&amp;gt;45&amp;lt;/b&amp;gt;
&amp;lt;/a&amp;gt;
n&amp;lt;/root&amp;gt;&lt;/PRE&gt;&lt;P&gt;And After ConvertRecord Prceossor :&lt;/P&gt;&lt;PRE&gt;{"a": {"b":45}}&lt;/PRE&gt;&lt;P&gt;Hope that helps. If it does, please Accept Solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 17:42:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349104#M235523</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-29T17:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349272#M235586</link>
      <description>&lt;P&gt;Thank you SAMSL for your response.&amp;nbsp; In the interest of scalability I was trying to avoid performing text manipulations.&amp;nbsp; I ultimately decided to go with an XSLT transform since this processor is optimized for performing these types of operations, making it more scalable.&amp;nbsp; I wanted to verify there wasn't an option within the XMLReader that I was missing, but it seems not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On a side note, as an intellectual curiosity I also tried using the QueryRecord processor to see if I could select the outermost element in a query and slap wrapper text around it.&amp;nbsp; But it seems there is no way to perform this task with an XMLReader because it can't discern the schema of the data, so "select * from flowfile" is the only thing that works apparently.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 14:26:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349272#M235586</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-08-01T14:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349292#M235594</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98065"&gt;@ChuckE&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do your XML messages conform to defined a schema?&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;</description>
      <pubDate>Mon, 01 Aug 2022 21:57:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349292#M235594</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-08-01T21:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349297#M235599</link>
      <description>&lt;P&gt;Yes, I validate the incoming xml with a strongly typed xsd.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 00:30:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349297#M235599</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-08-02T00:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349400#M235642</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98065"&gt;@ChuckE&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use a JoltTransformRecord processor to perform the conversion to JSON and, at the same time, add the root node back to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="araujo_0-1659503928628.png" style="width: 632px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35093i1A79E7AF6E8C6473/image-dimensions/632x480?v=v2" width="632" height="480" role="button" title="araujo_0-1659503928628.png" alt="araujo_0-1659503928628.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The JOLT specification I used is this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "*": "a.&amp;amp;"
}&lt;/LI-CODE&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 05:20:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349400#M235642</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-08-03T05:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349404#M235644</link>
      <description>&lt;P&gt;This seems like a good idea.&amp;nbsp; I'll give this a try and test the performance against the XSLT transform.&amp;nbsp; I've never used the JOLT processors before so this will be a good opportunity to experiment with one.&amp;nbsp; Thanks for the idea.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 05:41:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349404#M235644</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-08-03T05:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349405#M235645</link>
      <description>&lt;P&gt;I'm also curious about the performance difference. If you could report your results here, I'd appreciate!&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>Wed, 03 Aug 2022 05:43:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349405#M235645</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-08-03T05:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349475#M235670</link>
      <description>&lt;P&gt;I've since discovered a super easy way to resolve this.&amp;nbsp; Simply using the XMLRecordSetWriter does EXACTLY what I was looking for.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 17:13:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349475#M235670</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-08-03T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349497#M235677</link>
      <description>&lt;P&gt;Can you explain how did you resolve it with XMLRecrodSetWriter? Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 02:24:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349497#M235677</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-08-04T02:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349499#M235678</link>
      <description>&lt;P&gt;Ahh! Good catch,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98065"&gt;@ChuckE&lt;/a&gt;&amp;nbsp;!! So simple!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="araujo_0-1659580409302.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35106i7B07F101CB7BFF14/image-size/medium?v=v2&amp;amp;px=400" role="button" title="araujo_0-1659580409302.png" alt="araujo_0-1659580409302.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 02:33:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349499#M235678</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-08-04T02:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Preserving the parent element in XML document with XMLReader</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349500#M235679</link>
      <description>&lt;P&gt;I create an XMLRecordSetWriter in the Controller Services, then using a ConvertRecord processor I'm able to read the xml record and then immediately write it out with a new root tag, which I can then pass to my next processor.&amp;nbsp; I discovered this when I was reading the documentation for the XMLRecordSetWriter.&amp;nbsp; Very first line in the documentation.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.7.0/org.apache.nifi.xml.XMLRecordSetWriter/index.html" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.7.0/org.apache.nifi.xml.XMLRecordSetWriter/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 02:59:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Preserving-the-parent-element-in-XML-document-with-XMLReader/m-p/349500#M235679</guid>
      <dc:creator>ChuckE</dc:creator>
      <dc:date>2022-08-04T02:59:53Z</dc:date>
    </item>
  </channel>
</rss>

