Dynamically create repetition XML

mardi 16 décembre 2014

Hello all!



I got some troubles with dynamic generation of segments in a XML variable.

The approach is to make template functions for generating standard segments.



I would like to generate dynamically a PID segment like this:


Quote:








PID||data1|data2~data3||



To do that i create a new XML with PID tag, and add programatically the data, this code is embedded in a template, cannot acces to output template where i can create the repetition ~.


Quote:








var segment = new XML(<PID></PID>);

segment['PID.2']['PID.2.1']='data1';

segment['PID.3'][0]['PID.3.1']='data2'; --> It fails because not exists the 1º repetition [0]

segment['PID.3'][1]['PID.3.1']='data3';



How can i create repetition tags programatically?

I have tried to use the appendChild function, but an expection was launch (appendChild is not a function, it is xml.)


Quote:








var newseg = new XML(<PID.3.1></PID.3.1>);

newseg='data2';

segment['PID.3'].appendChild(newseg);



Thanks for all!





Dynamically create repetition XML

0 commentaires:

Enregistrer un commentaire