flex4 - A better way updating a nested XML -


i have few lines of code:

 lev = arrinfo[1]  xml = sxml;  switch(lev){  case 0: xml = sxml;  break;  case 1: var xl:xml = arrinfo[0];  xml.sublevels = xl;  break;  case 2: xl = arrinfo[0];  xml.sublevels.sublevel.sublevels = xl;  break;  case 3: xl = arrinfo[0];                                                                               xml.sublevels.sublevel.sublevels.sublevel.sublevels = xl;  break; } 

in switch statement, checks level of sublevels xl xml should attached , based on level, goes attach it. so, if level three, means xl should substitute sublevels in level. in case 3: xl substitutes sublevels in sublevel node of (level-1) sublevels node , if have case 4: xl should replace sublevels of sublevel node of (4-1) sublevels. this:

 case 4: xl = arrinfo[0];                                                                               xml.sublevels.sublevel.sublevels.sublevel.sublevels.sublevel.sublevels = xl; 

however, means have manually if know number of sublevels in nested xml, of work if levels 20 or adds new level not manually checked in switch statement.

anyone knows how can solve problem?


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -