Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
DavidFoster1
Specialist
Specialist

XML - Reading data - Parent Elements

One for the QV XML gurus

In an XML Load statement is it possible to make references to attributes of elements above the table-element in your FROM statement. I want to define my own foreign keys by looking a the ID attribute of the parent element.

Thoughts?

4 Replies
Colin-Albert

Hi David,

I believe that the QlikView  XML option will only access TABLE tags.

You could extract the data as text and process it through TEXTBETWEEN functions to extract other tags outside the TABLE tags, possibly with other functions like SUBFIELD to extract the data.


DavidFoster1
Specialist
Specialist
Author

This is has raised its ugly head again. Any assistance gratefully received.

flipside
Partner - Specialist II
Partner - Specialist II

I'm not 100% sure on what you are trying to do, but could you amend the xml using the load script like this ...

xmlraw:

Load '<UserPrefs>' as '<head>' autogenerate 1;
Load '<UserId>abcdef</UserId>' as '<head>' autogenerate 1;
Load '</UserPrefs>' as '<head>' autogenerate 1;
LOAD @1:n as '<head>'
FROM
[AllProperties.xml] (
fix, utf8);
Load '</head>' AS '<head>' autogenerate 1;

STORE xmlraw into [AllProperties2.xml] (txt);

flipside


DavidFoster1
Specialist
Specialist
Author

The approach I have used in the end was to loop through the XML files one by one and use LEFT JOINs using the derived XML keys and the real foreign key to add the keys to the child tables. I did try ApplyMap but I couldn't drop the mapping tables for each loop which caused incorrect mappings.