« Here are my Terms & Conditions Main | Integrating BIP with Oracle Database Security »

Loopin' Trick

An old question and Im not sure why it bubbled to the top of the forum today. Question is from Ruth:


Can anyone help?
I have XML output from the PO Output for Communication report which looks like this

<LINE_ATTACHMENTS>
<TEXT>SLC CUSTOMER REFERENCE=100</TEXT>
<ID>2679</ID>
<TEXT>SLC CUSTOMER REFERENCE=88</TEXT>
<ID>2680</ID>
<TEXT>SLC CUSTOMER REFERENCE=5512</TEXT>
<ID>2681</ID>
</LINE_ATTACHMENTS>

I need to display all three of the text fields but cant seem to find a way to do it. I have tried for-each and if statments but they only show the 1st text field, I cant seem to find away to display the 2nd and 3rd ones.

Can anyone help?


Ruth really really needed help - Im happy to say it was not me answering but one of our active forum members 'vetsrini' - sorry Sir or Marm I can identify you no further from the forum.


You folks need to share your names in your posts or handles - its so much easier to reply to 'John' or even 'Dr Plexi' than User353533 - get a cool handle such as 'The Tick' or maybe 'Sleepless in Seattle' - cheesy maybe, but we know two things about you already - you live 'up t'North' and you're an insomiac who watches mushy flicks with Tom Hanks in it - must be those long rainy nights. Sorry, 'Seattlites' - I have been to Washington about 6 times now and every time it been raining - its always very 'green' in your neck of the woods.


Back to Ruth's issue and 'Vet's' solution  - hope you dont mind I gave you a nickname. Ruth wanted a table showing 'ID' and 'Text' in a two columned table and was a little stuck on how to construct the loop required. Looking at the XML the elements needed are wrapped in the LINE_ATTACHMENTS element but just looping over that:


<?for-each:LINE_ATTACHMENTS?>
<?ID?>       <?TEXT?>
<?end for-each?>


will only give us the first members of the set. You can actually take the looping down a level further ie for-each:LINE_ATTACHMENTS/ID and for-each:LINE_ATTACHMENTS/TEXT and get the looping correct. We now have two loops in their own cells.


FELoop1:


Here's the contents of the fields.


FELoop2:


Notice that we use '.' in the ID and Text fields - this tells the rendering engine 'insert the current element here' ie the TEXT or ID column thats we are looping on. Now we get out like:


FELoop3:


Thanks for the solution 'Vet' and 'Ruth' for the question - keep em coming!

Comments (1)

Vetri:

Hi Tim,
Its me again, Vetsrini.
Iam happy you mention my name in your page.
As i mentioned in the forum thread, there are many ways to do this.

the another way is :).

You can do this in this way too.
create a table with two rows and two column,
in the first row give the heading for the each column as TEXT and ID

n the second row, first column,
type this
<?for-each:LINE_ATTACHMENTS/TEXT?><?.?>

in the second row, second column,
type this
<?following-sibling::.[1]?> <?end for-each?>

I just put comments here , so that you add this to your blog too :).
Thanks,
Vetri

Post a comment