Qlik Community

QlikView Documents

Documents for QlikView related information.

Generic XML Import

Partner
Partner

Generic XML Import

QlikView's xml import utility is great if you have to bring in lots of the same kind of XML file. It doesn't work so well though if you have a lot of different types of xml files. Since XML is a W3C recommended standard I always thought it should be possible to make a script based on those standards that would logically parse any XML file.

That just what this does. It creates four tables as follows:

Files : A list of the files that were imported with path and generated ID

Hierarchy :  A list of all XML elements their, hierarchy level, and their parent information

Values :  A list of the XML values keyed back to their source element

Attributes :  A list of the XML attributes keyed back to their source element

It's a first draft so I'm sure the script could be tightened up a bit and I may have missed some scenarios. I did throw if a few intentional malformed xml files and it even sorted those out. I thought I'd pass it on in case anyone else may have use of something like this. I checked around before I built it but I couldn't find anything like it.

I've attached a dummy XML document and the QVW where it's been imported.

Tags (1)
Labels (2)
Attachments
Comments
Not applicable

Hi Benjamin,

Thanks for sharing !

I used it to list the Fields of several XML which had almost the same structure.

The only thing I would modify in your code is the way you split the Attributes :

This is yours :     Subfield(Attributes,' ') as Attrib,

This is mine :      Subfield(Attributes,'" ')&'"' as Attrib,

(XML Element Attributes tab)

This avoid to corrupt the split when a AttributeValue contains a space.

I am not an XML expert, so I don't know if this fits with the standard, but it worked for me.

Cheers,

Emilien

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2014-09-22 04:05 PM
Updated by:
Partner