Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

XML with "column headers" as Metadata

It's been a long time since I've had to do XML parsing. I have XML data from a Cognos report that has a metadata section with items containing the equivalent of table header names. I feel close to solving this, but am probably missing something simple and am getting sleep deprived. My current attempts are around numbering the header metadata with RowNo() and then trying to match the Items back since all metadata header items are represented in my rows of data.

Any suggestions on how to read this data?

3 Replies
Gysbert_Wassenaar

Try this:

item:

LOAD name,

    type,

    length,

    precision,

    RowNo() as ValueRowNo

FROM [Project Status Report Export.xml] (XmlSimple, Table is [dataset/metadata/item]);

LET vMax = Peek('ValueRowNo',-1,item);

'dataset/data/row/value':

LOAD value%Table,

    if(rowno()>1 and peek('ValueRowNo')< $(vMax) ,peek('ValueRowNo')+1,1) as ValueRowNo

FROM [Project Status Report Export.xml] (XmlSimple, Table is [dataset/data/row/value]);


talk is cheap, supply exceeds demand
Not applicable
Author

That's pretty close but I need to keep the <row></row> groupings together. Is there some way when reading the row/values to increment a counter for each row?  That should let me group on that row counter.

Rick

Gysbert_Wassenaar

item:

LOAD name,

    type,

    length,

    precision,

    RowNo() as ValueRowNo

FROM [Project Status Report Export.xml] (XmlSimple, Table is [dataset/metadata/item]);

LET vMax = Peek('ValueRowNo',-1,item);

'dataset/data/row/value':

LOAD value%Table,

    if(rowno()>1 and peek('ValueRowNo')< $(vMax) ,peek('ValueRowNo')+1,1) as ValueRowNo,

    ceil(RowNo()/$(vMax)) as Row

FROM [Project Status Report Export.xml] (XmlSimple, Table is [dataset/data/row/value]);


talk is cheap, supply exceeds demand