2 Replies Latest reply: Feb 2, 2017 2:57 AM by Samuel LEFRANC RSS

    Load xml nodes as a unique field

    Samuel LEFRANC

      Hi,

       

      Is there a way, when your script have to load an xml file, to create a field whose contents is a full node of the original xml file ?

       

      Let's take a very simple example. Here is the xml source file body (find the file in attachement)

      <?xml version="1.0" encoding="UTF-8"?>

      <student>

        <firstname>John</firstname>

        <lastname>DOE</lastname>

        <items>

          <item>

            <code>A</code>

            <value>10</value>

          </item>

          <item>

            <code>B</code>

            <value>20</value>

          </item>

        </items>

      </student>

       

      If i use the wizard to load this file, Qlikview will generate 2 tables

      item:

      LOAD code,

          value,

          %Key_student_C932B46F5721DF6D    // Key to parent table: student

      FROM [C:\Temp\sample.xml] (XmlSimple, Table is [student/items/item]);

       

      student:

      LOAD firstname,

          lastname,

          %Key_student_C932B46F5721DF6D    // Key for this table: student

      FROM [C:\Temp\sample.xml] (XmlSimple, Table is [student]);

       

      My Goal is to have only3 fields, one of them containing the all node "items". Something like that :

      firstname

      lastname items
      JohnDOE<item><code>A</code><value>10</value></item><item><code>B</code><value>20</value></item>

       

      Why that ? Because for the moment, I don't need any information about "items", but I want to collect this information and store it in my QVD, so that I will be able to parse it later if needed.

      Have in mind that the node I want to store as it is is more complicated as in this example. It could contain other nodes which could contain other nodes... which would give me many tables linked each one to others, when I just need a way to store the information for later use.

       

      Is there a way, or a trick, to get to that ?

       

      Thanks for your help.

       

      Sam