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

Announcements
Maximize ROI with Qlik Professional Services – Expert Guidance, Faster Results: Explore Qlik Services
cancel
Showing results for 
Search instead for 
Did you mean: 
Alpha549
Creator II
Creator II

Format XML structure

Hello everyone !

Here is a test job :

 

0683p000009M1lg.png

 

And the tFixedFlowInput configuration :

 

0683p000009M1o1.png

 

The tXML_Map configuration :

 

0683p000009M1xg.png

 

I get this XML string :

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>15</stat>
	</student>
	<student>
		<name>B</name>
		<stat>13</stat>
	</student>
	<student>
		<name>A</name>
		<stat>13</stat>
	</student>
	<student>
		<name>A</name>
		<stat>17</stat>
	</student>
	<student>
		<name>B</name>
		<stat>14</stat>
	</student>
	<student>
		<name>C</name>
		<stat>12</stat>
	</student>
</students>

I wonder if it's possible to "aggregate" values and get rather this XML string :

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>15</stat>
		<stat>13</stat>
		<stat>17</stat>
	</student>
	<student>
		<name>B</name>
		<stat>13</stat>
		<stat>14</stat>
	</student>
	<student>
		<name>C</name>
		<stat>12</stat>
	</student>
</students>

This structure would be kind of difficult to read because here a student could have an infinity of stats, I'm aware of that, BUT, just by curiosity, I would like to know if it's possible to generate XML like this ? 

 

Thanks ! 0683p000009MACn.png

Labels (4)
1 Solution

Accepted Solutions
Alpha549
Creator II
Creator II
Author

Using tSortRow + student as group + stat as loop I get this : 

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>13</stat>
		<stat>15</stat>
		<stat>17</stat>
	</student>
	<student>
		<name>B</name>
		<stat>13</stat>
		<stat>14</stat>
	</student>
	<student>
		<name>C</name>
		<stat>12</stat>
	</student>
</students>

That's nice ! 0683p000009MACn.png

It's clear that the work would be more difficult if there are sub elements in stat, with loops...

 

Thank you for your help !

I think that 

View solution in original post

7 Replies
Tech8
Contributor III
Contributor III

Could you try adding in the tXMLMap (out1) the loop to the stat tag instead of the student tag? I didnt tested it so im not sure if this will work in your case.

 

 

tjohn
Contributor
Contributor

Hello, 

give a try to this  : put an aggregate on name and loop on stat

 

Thanks and regards

 

tjclearner

Alpha549
Creator II
Creator II
Author

Hello,

When I only set stat as loop I get :

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>15</stat>
		<stat>13</stat>
		<stat>13</stat>
		<stat>17</stat>
		<stat>14</stat>
		<stat>12</stat>
	</student>
</students>

I couldn't create a group on name so I tried to create a loop on stat and then a group on student.

I get this XML file :

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>15</stat>
	</student>
	<student>
		<name>B</name>
		<stat>13</stat>
	</student>
	<student>
		<name>A</name>
		<stat>13</stat>
		<stat>17</stat>
	</student>
	<student>
		<name>B</name>
		<stat>14</stat>
	</student>
	<student>
		<name>C</name>
		<stat>12</stat>
	</student>
</students>

Almost ! 😕

tjohn
Contributor
Contributor

hello, 

why not use first a tsortrow  then :

put an aggregate on name

and loop on stat

 

Thanks

Tech8
Contributor III
Contributor III

Try setting up the "All in one" option as true and run the job again. This with my example because if you are using aggregate you have to set it as false (check this aswell).

 

0683p000009M1yZ.png

Alpha549
Creator II
Creator II
Author

Using tSortRow + student as group + stat as loop I get this : 

 

<?xml version="1.0" encoding="UTF-8"?>
<students>
	<student>
		<name>A</name>
		<stat>13</stat>
		<stat>15</stat>
		<stat>17</stat>
	</student>
	<student>
		<name>B</name>
		<stat>13</stat>
		<stat>14</stat>
	</student>
	<student>
		<name>C</name>
		<stat>12</stat>
	</student>
</students>

That's nice ! 0683p000009MACn.png

It's clear that the work would be more difficult if there are sub elements in stat, with loops...

 

Thank you for your help !

I think that 

tjohn
Contributor
Contributor

Nice 0683p000009MA9p.png
put it as resolved.
Thanks