<?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: Can I query nested XML data (over REST) such that I get a flat table? in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1951870#M11018</link>
    <description>&lt;P&gt;Have you managed to create a workaround, I've submitted this as a "new" idea&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Suggest-an-Idea/REST-Connector-support-for-nested-JSON-and-XML-response/idi-p/1951867#M9898" target="_blank"&gt;https://community.qlik.com/t5/Suggest-an-Idea/REST-Connector-support-for-nested-JSON-and-XML-response/idi-p/1951867#M9898&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jul 2022 14:01:09 GMT</pubDate>
    <dc:creator>p_verkooijen</dc:creator>
    <dc:date>2022-07-05T14:01:09Z</dc:date>
    <item>
      <title>Can I query nested XML data (over REST) such that I get a flat table?</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1568751#M3825</link>
      <description>&lt;P&gt;Hey folks.&lt;/P&gt;&lt;P&gt;I am using Qlik to report on vehicle usage data. The data is in a tracking system that provides a rather limited SOAP API returning XML data that looks like...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="fleettestlive.cartrack.com.hk/api/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&amp;gt;
   &amp;lt;SOAP-ENV:Body&amp;gt;
      &amp;lt;ns1:endpoint.get_all_tripsResponse xmlns:ns1="fleettestlive.cartrack.com.hk/api/"&amp;gt;
         &amp;lt;SqlResult0 xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:get_all_tripsResultType0Row[472]"&amp;gt;
            &amp;lt;item xsi:type="tns:get_all_tripsResultType0Row"&amp;gt;
               &amp;lt;vehicle_id xsi:type="xsd:decimal"&amp;gt;1234&amp;lt;/vehicle_id&amp;gt;
               &amp;lt;start_timestamp xsi:type="xsd:string"&amp;gt;2017-03-19 16:51:09+08&amp;lt;/start_timestamp&amp;gt;
               &amp;lt;end_timestamp xsi:type="xsd:string"&amp;gt;2017-03-19 16:57:17+08&amp;lt;/end_timestamp&amp;gt;
               &amp;lt;start_location xsi:type="xsd:string"&amp;gt;Start location content&amp;lt;/start_location&amp;gt;
               &amp;lt;end_location xsi:type="xsd:string"&amp;gt;End location content&amp;lt;/end_location&amp;gt;
               &amp;lt;trip_distance xsi:type="xsd:decimal"&amp;gt;2784&amp;lt;/trip_distance&amp;gt;
               &amp;lt;trip_time xsi:type="xsd:string"&amp;gt;00:06:08&amp;lt;/trip_time&amp;gt;
               &amp;lt;registration xsi:type="xsd:string"&amp;gt;XYZ123&amp;lt;/registration&amp;gt;
               &amp;lt;driver_id xsi:type="xsd:string"&amp;gt;1234&amp;lt;/driver_id&amp;gt;
               &amp;lt;driver xsi:type="xsd:string"&amp;gt;driver content&amp;lt;/driver&amp;gt;
               &amp;lt;driver_id_number xsi:type="xsd:string"&amp;gt;12341234&amp;lt;/driver_id_number&amp;gt;
               &amp;lt;client_vehicle_description xsi:type="xsd:string"&amp;gt;Vehicle desc&amp;lt;/client_vehicle_description&amp;gt;
            &amp;lt;/item&amp;gt;
            &amp;lt;item xsi:type="tns:get_all_tripsResultType0Row"&amp;gt;
               &amp;lt;vehicle_id xsi:type="xsd:decimal"&amp;gt;1234&amp;lt;/vehicle_id&amp;gt;
               &amp;lt;start_timestamp xsi:type="xsd:string"&amp;gt;2017-03-19 16:51:09+08&amp;lt;/start_timestamp&amp;gt;
               &amp;lt;end_timestamp xsi:type="xsd:string"&amp;gt;2017-03-19 16:57:17+08&amp;lt;/end_timestamp&amp;gt;
               &amp;lt;start_location xsi:type="xsd:string"&amp;gt;Start location content&amp;lt;/start_location&amp;gt;
               &amp;lt;end_location xsi:type="xsd:string"&amp;gt;End location content&amp;lt;/end_location&amp;gt;
               &amp;lt;trip_distance xsi:type="xsd:decimal"&amp;gt;2784&amp;lt;/trip_distance&amp;gt;
               &amp;lt;trip_time xsi:type="xsd:string"&amp;gt;00:06:08&amp;lt;/trip_time&amp;gt;
               &amp;lt;registration xsi:type="xsd:string"&amp;gt;XYZ123&amp;lt;/registration&amp;gt;
               &amp;lt;driver_id xsi:type="xsd:string"&amp;gt;1234&amp;lt;/driver_id&amp;gt;
               &amp;lt;driver xsi:type="xsd:string"&amp;gt;driver content&amp;lt;/driver&amp;gt;
               &amp;lt;driver_id_number xsi:type="xsd:string"&amp;gt;12341234&amp;lt;/driver_id_number&amp;gt;
               &amp;lt;client_vehicle_description xsi:type="xsd:string"&amp;gt;Vehicle desc&amp;lt;/client_vehicle_description&amp;gt;
            &amp;lt;/item&amp;gt;
         &amp;lt;/SqlResult0&amp;gt;
      &amp;lt;/ns1:endpoint.get_all_tripsResponse&amp;gt;
   &amp;lt;/SOAP-ENV:Body&amp;gt;
&amp;lt;/SOAP-ENV:Envelope&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I feed that data to Qlik as an XML &lt;EM&gt;file&lt;/EM&gt;, Qlik automatically gives me a lovely flat table in which each row is an "item". Doing it this way Qlik generates a very neat little query which I modify slightly to yield roughly this.&lt;/P&gt;&lt;PRE&gt;[VehicleData]:
LOAD
	[vehicle_id],
	[start_timestamp],
	[end_timestamp],
	[start_location],
	[end_location],
	[trip_distance],
	[trip_time],
	[registration],
	[driver_id],
	[driver],
	[driver_id_number],
	[client_vehicle_description],
	[driver_id/xsi:nil]
 FROM [lib://datasource name]
(XmlSimple, table is [Envelope/Body/endpoint.get_all_tripsResponse/SqlResult0/item], URL is [$(i)])
WHERE trip_distance &amp;gt; 0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To access the data &lt;EM&gt;directly&lt;/EM&gt;&amp;nbsp;from the system, however, I need to use the&amp;nbsp;REST connector so I can do authentication, set a bunch of headers and use a POST.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do that Qlik takes a far more advanced approach to the XML . It treats each field as a table linked by generated keys. The query syntax that Qlik is generating is &lt;A href="https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Load-REST-data/Load-data.htm#anchor-4" target="_blank" rel="noopener"&gt;described in the help here&lt;/A&gt; but it is proving a bit beyond my ability to modify the query to get the same simple table of data that Qlik's file reader provides.&lt;/P&gt;&lt;P&gt;Does anyone know a way I might be able to get the same flat table of results that the XML file reader gives me but using the REST connection?&lt;/P&gt;&lt;P&gt;For what it's worth, this the query Qlik generates when I use "select data" from the REST connector in the data load editor. I've tried to modify it to yield a flat table result but I'm not sure how to go about that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LIB CONNECT TO 'datasource name';

RestConnectorMasterTable:
SQL SELECT 
	"__KEY_Envelope",
	(SELECT 
		(SELECT 
			(SELECT 
				(SELECT 
					(SELECT 
						"@Content",
						"__FK_vehicle_id"
					FROM "vehicle_id" FK "__FK_vehicle_id" ContentFieldAlias "@Content"),
					(SELECT 
						"@Content" AS "@Content_u0",
						"__FK_start_timestamp"
					FROM "start_timestamp" FK "__FK_start_timestamp" ContentFieldAlias "@Content_u0"),
					(SELECT 
						"@Content" AS "@Content_u1",
						"__FK_end_timestamp"
					FROM "end_timestamp" FK "__FK_end_timestamp" ContentFieldAlias "@Content_u1"),
					(SELECT 
						"@Content" AS "@Content_u2",
						"__FK_start_location"
					FROM "start_location" FK "__FK_start_location" ContentFieldAlias "@Content_u2"),
					(SELECT 
						"@Content" AS "@Content_u3",
						"__FK_end_location"
					FROM "end_location" FK "__FK_end_location" ContentFieldAlias "@Content_u3"),
					(SELECT 
						"@Content" AS "@Content_u4",
						"__FK_trip_distance"
					FROM "trip_distance" FK "__FK_trip_distance" ContentFieldAlias "@Content_u4"),
					(SELECT 
						"@Content" AS "@Content_u5",
						"__FK_trip_time"
					FROM "trip_time" FK "__FK_trip_time" ContentFieldAlias "@Content_u5"),
					(SELECT 
						"@Content" AS "@Content_u6",
						"__FK_registration"
					FROM "registration" FK "__FK_registration" ContentFieldAlias "@Content_u6"),
					(SELECT 
						"@Content" AS "@Content_u7",
						"__FK_driver_id"
					FROM "driver_id" FK "__FK_driver_id" ContentFieldAlias "@Content_u7"),
					(SELECT 
						"@Content" AS "@Content_u8",
						"__FK_driver"
					FROM "driver" FK "__FK_driver" ContentFieldAlias "@Content_u8"),
					(SELECT 
						"@Content" AS "@Content_u9",
						"__FK_driver_id_number"
					FROM "driver_id_number" FK "__FK_driver_id_number" ContentFieldAlias "@Content_u9"),
					(SELECT 
						"@Content" AS "@Content_u10",
						"__FK_client_vehicle_description"
					FROM "client_vehicle_description" FK "__FK_client_vehicle_description" ContentFieldAlias "@Content_u10")
				FROM "item" PK "__KEY_item" FK "__FK_item")
			FROM "SqlResult0" PK "__KEY_SqlResult0" FK "__FK_SqlResult0")
		FROM "endpoint.get_all_tripsResponse" PK "__KEY_endpoint.get_all_tripsResponse" FK "__FK_endpoint.get_all_tripsResponse")
	FROM "Body" PK "__KEY_Body" FK "__FK_Body")
FROM XML "Envelope" PK "__KEY_Envelope";

[vehicle_id]:
LOAD	[@Content] AS [@Content]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_vehicle_id]);


[start_timestamp]:
LOAD	[@Content_u0] AS [@Content_u0]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_start_timestamp]);


[end_timestamp]:
LOAD	[@Content_u1] AS [@Content_u1]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_end_timestamp]);


[start_location]:
LOAD	[@Content_u2] AS [@Content_u2]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_start_location]);


[end_location]:
LOAD	[@Content_u3] AS [@Content_u3]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_end_location]);


[trip_distance]:
LOAD	[@Content_u4] AS [@Content_u4]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_trip_distance]);


[trip_time]:
LOAD	[@Content_u5] AS [@Content_u5]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_trip_time]);


[registration]:
LOAD	[@Content_u6] AS [@Content_u6]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_registration]);


[driver_id]:
LOAD	[@Content_u7] AS [@Content_u7]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_driver_id]);


[driver]:
LOAD	[@Content_u8] AS [@Content_u8]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_driver]);


[driver_id_number]:
LOAD	[@Content_u9] AS [@Content_u9]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_driver_id_number]);


[client_vehicle_description]:
LOAD	[@Content_u10] AS [@Content_u10]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_client_vehicle_description]);


DROP TABLE RestConnectorMasterTable;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Dec 2021 14:01:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1568751#M3825</guid>
      <dc:creator>crossroadsit</dc:creator>
      <dc:date>2021-12-21T14:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I query nested XML data (over REST) such that I get a flat table?</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1582702#M3956</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Qilk REST connector does not yet support flattening nested XML/ JSON responses. There is an ongoing feature request for this as far as I know. This article&amp;nbsp;&lt;A href="https://support.qlik.com/articles/000074304" target="_blank"&gt;https://support.qlik.com/articles/000074304&lt;/A&gt;&amp;nbsp;gives some more discussion (actually it's making a reference to your community post).&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 12:13:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1582702#M3956</guid>
      <dc:creator>Vu_Nguyen</dc:creator>
      <dc:date>2019-05-21T12:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can I query nested XML data (over REST) such that I get a flat table?</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1951870#M11018</link>
      <description>&lt;P&gt;Have you managed to create a workaround, I've submitted this as a "new" idea&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Suggest-an-Idea/REST-Connector-support-for-nested-JSON-and-XML-response/idi-p/1951867#M9898" target="_blank"&gt;https://community.qlik.com/t5/Suggest-an-Idea/REST-Connector-support-for-nested-JSON-and-XML-response/idi-p/1951867#M9898&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 14:01:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Can-I-query-nested-XML-data-over-REST-such-that-I-get-a-flat/m-p/1951870#M11018</guid>
      <dc:creator>p_verkooijen</dc:creator>
      <dc:date>2022-07-05T14:01:09Z</dc:date>
    </item>
  </channel>
</rss>

