<?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>topic Re: parse xml with prefix - cSetHeader in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285798#M59420</link>
    <description>&lt;P&gt;This can be a bit tricky in the ESB toolset. You are required to do more of the coding yourself here. But this is how you can achieve this.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;First of all, your XML is not valid. I suspect that you have taken this from a Java String since you are escaping quotes (using backslashes). Your XML should look like this....&lt;/P&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" ?&amp;gt;
&amp;lt;S:Envelope
	xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&amp;gt;
	&amp;lt;S:Body&amp;gt;
		&amp;lt;ns2:uploadResponse
			xmlns:ns2="http://upload.service.ws.findxnet.com/"&amp;gt;
			&amp;lt;return&amp;gt;
				&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;
			&amp;lt;/return&amp;gt;
		&amp;lt;/ns2:uploadResponse&amp;gt;
	&amp;lt;/S:Body&amp;gt;
&amp;lt;/S:Envelope&amp;gt;&lt;/PRE&gt; 
&lt;P&gt;I'll show a dummy route that I configured to test this. The route looks like this...&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-01-15 at 12.12.11.png" style="width: 846px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M1x2.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129010i41DF0692736A8D41/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M1x2.png" alt="0683p000009M1x2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;I am reading from a file using a cFile, then reading the XML using the cSetHeader and then outputting the result using a tiny bit of code in the cProcessor component.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The cSetHeader component is configured as below.....&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-01-15 at 12.12.42.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M1x7.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145024iEBD316D3F7224109/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M1x7.png" alt="0683p000009M1x7.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;I called the header "CodeHeader". I am using XPath as the language. The XPath is "/S:Envelope/S:Body/ns2:uploadResponse/return/code/text()".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In order to extract this we need to also configure the namespaces. This can be seen in the "Namespaces" table below.&lt;/P&gt; 
&lt;P&gt;In the cProcessor component, I have the following code....&lt;/P&gt; 
&lt;PRE&gt;System.out.println((String)exchange.getIn().getHeader("CodeHeader", String.class));&lt;/PRE&gt; 
&lt;P&gt;This simply prints the value of the "CodeHeader" header to the terminal.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jan 2019 12:20:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-01-15T12:20:54Z</dc:date>
    <item>
      <title>parse xml with prefix - cSetHeader</title>
      <link>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285797#M59419</link>
      <description>&lt;P&gt;I don't know how to parse this XML with Prefixes:&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version=\"1.0\" ?&amp;gt;
&amp;lt;S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"&amp;gt;
	&amp;lt;S:Body&amp;gt;
		&amp;lt;ns2:uploadResponse xmlns:ns2=\"http://upload.service.ws.findxnet.com/\"&amp;gt;
			&amp;lt;return&amp;gt;
				&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;
			&amp;lt;/return&amp;gt;
		&amp;lt;/ns2:uploadResponse&amp;gt;
	&amp;lt;/S:Body&amp;gt;
&amp;lt;/S:Envelope&amp;gt;&lt;/PRE&gt;&lt;P&gt;with cSetHeader Component.&lt;/P&gt;&lt;P&gt;I would need the code value of 0.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:51:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285797#M59419</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T06:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: parse xml with prefix - cSetHeader</title>
      <link>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285798#M59420</link>
      <description>&lt;P&gt;This can be a bit tricky in the ESB toolset. You are required to do more of the coding yourself here. But this is how you can achieve this.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;First of all, your XML is not valid. I suspect that you have taken this from a Java String since you are escaping quotes (using backslashes). Your XML should look like this....&lt;/P&gt; 
&lt;PRE&gt;&amp;lt;?xml version="1.0" ?&amp;gt;
&amp;lt;S:Envelope
	xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&amp;gt;
	&amp;lt;S:Body&amp;gt;
		&amp;lt;ns2:uploadResponse
			xmlns:ns2="http://upload.service.ws.findxnet.com/"&amp;gt;
			&amp;lt;return&amp;gt;
				&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;
			&amp;lt;/return&amp;gt;
		&amp;lt;/ns2:uploadResponse&amp;gt;
	&amp;lt;/S:Body&amp;gt;
&amp;lt;/S:Envelope&amp;gt;&lt;/PRE&gt; 
&lt;P&gt;I'll show a dummy route that I configured to test this. The route looks like this...&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-01-15 at 12.12.11.png" style="width: 846px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M1x2.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129010i41DF0692736A8D41/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M1x2.png" alt="0683p000009M1x2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;I am reading from a file using a cFile, then reading the XML using the cSetHeader and then outputting the result using a tiny bit of code in the cProcessor component.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The cSetHeader component is configured as below.....&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-01-15 at 12.12.42.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M1x7.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145024iEBD316D3F7224109/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M1x7.png" alt="0683p000009M1x7.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;I called the header "CodeHeader". I am using XPath as the language. The XPath is "/S:Envelope/S:Body/ns2:uploadResponse/return/code/text()".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In order to extract this we need to also configure the namespaces. This can be seen in the "Namespaces" table below.&lt;/P&gt; 
&lt;P&gt;In the cProcessor component, I have the following code....&lt;/P&gt; 
&lt;PRE&gt;System.out.println((String)exchange.getIn().getHeader("CodeHeader", String.class));&lt;/PRE&gt; 
&lt;P&gt;This simply prints the value of the "CodeHeader" header to the terminal.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 12:20:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285798#M59420</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-15T12:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: parse xml with prefix - cSetHeader</title>
      <link>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285799#M59421</link>
      <description>&lt;P&gt;Why is this text() method at the end?&lt;/P&gt;&lt;P&gt;Also I think we don't need a cast to String.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 21:54:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285799#M59421</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-15T21:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: parse xml with prefix - cSetHeader</title>
      <link>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285800#M59422</link>
      <description>&lt;P&gt;The text() at the end removes the code tags surrounding the number. Otherwise you end up with &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The reason for casting to a String was that I tried different&amp;nbsp;code(without the String.class parameter as a parameter in the getHeader method) and simply left it in when I modified what I'd done. On looking at this, you are probably right that it is not needed. Just lazy testing on my part &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 10:22:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/parse-xml-with-prefix-cSetHeader/m-p/2285800#M59422</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-01-16T10:22:25Z</dc:date>
    </item>
  </channel>
</rss>

