From: fuglyducky Date: 2010-05-27T01:50:05+09:00 Subject: Re: XML Generator/Merger On May 26, 9:42 am, fuglyducky wrote: > Before I get into this, I need to say that I am not a programmer and > have very limited programming experience in any language, let alone > Ruby. With that said, Ruby is the language I know the best (which > really isn't saying much). Regardless... > > I have been working on a script that will take multiple predefined XML > template files and merge them as needed. I was able to do this by: > > 1. Convert file1 XML into an array where each line is an element in > the array > 2. Convert entire file2 into a string and insert it into the second to > last element in file1 array > (this is to insert a subsection of XML inside the tag of the > file1 XML > > Example: > > file1: >
>     >
> > file2: > >     > > > Merged: >
>     >     >         >     >
> > This works perfectly. My problem is that I need to randomize the > number of individual pieces like this... > > -single Header > -multiple subElem1 (1+) > -each subElem1 can contain multiple subElem2 (1+) > -each subElem2 may contain multiple subElem3 and subElem4 (1+) > > Keep in mind that each section has a closing tag so I need a way to > merge or insert and simply append. My thought was to create a > multidimensional array and merge from the bottom up but I was > wondering if there is a faster and/or cleaner way of doing this? It > doesn't have to be pretty or fast. > > Does anyone have any idea on how I should/could proceed? > > Thanks!!! Sorry...I was typing too fast... Keep in mind that each section has a closing tag so I need a way to merge or insert and NOT simply append.