Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reuse Element names

Hello,

I have some questions on Qlikview's load script.

My dataset looks like this :

<brands>

    <brand>

        <id>brand1</id>

        <name>Brand 1</name>

        <categories>

            <jeans>4</jeans>

        </categories>

    </brand>

    <brand>

        <id>brand2</id>

        <name>Brand 2</name>

        <categories>

            <coats>2</coats>

            <parkas>1</parkas>

            <shorts>1</shorts>

        </categories>

    </brand>

</brands>

The results I want should look like this :

NameCategory
Brand 1Jeans
Brand 2Coats
Brand 2Parkas
Brand 2Shorts

As you can see the problem is that the category names are tag names and that there are unlimited number of elements under the <categories> tag.

How can I get the tag name from an element and how can I link it to the brand name ?

It is possible to do that in the Load script ?

Thank you,

anita mazur

2 Replies
struniger
Creator
Creator

How about this (test.xml is just your data as given in your question).

// Start of [test.xml] LOAD statements

brand:

LOAD id,

    name,

    [categories/jeans] as jeans,

    [categories/coats] as coats,

    [categories/parkas] as parkas,

    [categories/shorts] as shorts

FROM [test.xml] (XmlSimple, Table is [brands/brand]);

// End of [test.xml] LOAD statements

tCategory:

Crosstable(Category, value, 2)

LOAD

  *

RESIDENT

  brand

;

Category:

LOAD

  id

  ,Category

  ,value

RESIDENT

  tCategory

WHERE value > 0;

DROP TABLE tCategory;

Not applicable
Author

Thank you very much. it works !