Recurse xml remove all but first child

Hi,
I've tried searching for a solution and tried to adapt the code i found but I'm stuck.
I simply want to:
Delete all children bar the first child of all elements named "gr_name".
I've been looking at Remove xml element using JS[CS3] and got some inspiration.
I have the below code, which works if there is only two child elements.
If there is three or more I have to rerun the code which removes more elements.
I would very much appreciate if someone can help me locate the error or indicate what is missing.
var myDoc = app.activeDocument;
Table_Remove (myDoc);
function Table_Remove(elm)
    for (var i = 0; i < elm.xmlElements.length; i++)
             if(elm.xmlElements[i].markupTag.name == "gr_table")
                    for (var i2 =1; i2 < elm.xmlElements[i].xmlElements.length; i2++)
                            elm.xmlElements[i].xmlElements[i2].remove();
            Table_Remove(elm.xmlElements[i]);

Thanks a lot!
I understand now.
while (this.getComponentCount() > 3) {this.remove(3);}
The JPanel's index-table is updated after removal of a component. The component at index 57 (for instance) is no longer at index 57 after removal of a component before index 57. That's why it removed every other component.

Similar Messages

  • Repair Problem with Excel Removing All But First External SQL Query Tables

    We have an Excel 2007 XLSX workbook that we created for doing some business analysis from the SQL database that contains data from our MRP system. It started as a single sheet with one data connection running a SQL query. The data comes into
    the spreadsheet as a table and there are some basic row and column sums being done.
    After getting the first version up and running without problems, we decided to add some additional sheets to the same workbook. Since each of these additional sheets had only slight variations to the SQL query and the formatting was all to be the same, we
    simply copied the first sheet and modified the data connection for each successive sheet (each copy automatically created a copy of the data connection as well). Everything seemed to be up and running properly, so we saved and closed the workbook.
    A little bit later, the same workbook was re-opened and Excel reported that "Excel found unreadable content in '<file name>'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes." If Yes
    is clicked, then Excel indicates the repairs that were made. Only one was made for each sheet beyond the first and that was "Removed Part: /xl/queryTables/queryTable2.xml part. (External data range)". The result was that the data connection
    was deleted from every sheet other than the first and only static data left in place.
    We thought it might have actual been some corruption, so we deleted the static sheets and recreated them the same way. After saving and closing, re-opening the file resulted in the same problem. It seems that Excel is somehow saving data that it can't read
    when it opens. I would think it could be something in the SQL query, but all sheets have essentially the same SQL query, so I'm not sure why the first sheet survives. As a result, I think it must be something that it does in copying the sheet and the corresponding
    data connections, but I'm not sure.
    I think this might be some kind of bug, but would like to know if anyone else has encountered a similar problem and found a solution. A few internet searches didn't give me much to check out.
    Thanks in advance,
    indyvql

    KR,
    Thanks for your response. I don't think it applies in this case since the file was created brand new in Excel 2007 and used in the same. There was no 3rd-party program involved. I'm also not migrating from 2003 to 2010 as the stellarinfo.com article
    suggests. Some of the other suggestions there also don't make any difference as all the data links are lost on opening the worksheet, so copying and pasting doesn't do any good.
    I tried to create a simple example by creating a new workbook with a sheet with a very simple SQL query ("select * from X where a > b"), but in that example it worked fine. I'm guessing there is something key about the much more complex SQL query
    in my original file with the problem, but I'm not sure why it would only affect copies of the data connection and not the original data connection itself.
    Thanks,
    indyvql

  • Can I remove all but the last "Mac OS X Server certificate management" application password from my System Keychain?

    I am slowly nursing a broken Montain Lion Server back to health. The problems started with a name change days ago then went sour, probably because of some stuff in the keychain that tripped the commands up.
    I have now a trusted Root CA in my System Keychain which has signed my wildcard Certificate for my domain and all my services are protected by this wildcard certificate. Creating and installing that certificate helped me back (slowly) but there are still problems to solve
    I also have set the com.apple.servermgrd identity preference to this (now trusted) wildcard certificate a few minutes ago
    I am busy cleaning as much as possibe of junk from my Keychains to improve stability, of course without damaging things (I hope)
    There are 19 "Mac OS X Server certificate management" application passwords in my System Keychain.
    12 are from 9 days ago when I installed this clean OS X Mountain Lion Server for the first time, created within a minute during server install.
    1 from 6 minutes later, maybe when I turned on a Service
    2 are from that day, but 2 and 3 hours later (also probably because of something I did in Server.app, like enabling a service)
    1 from 2 days later (probably when I tried to change the server name/domain)
    1 from again 5 days later (probably when I tried to change the server name/domain again)
    1 from yesterday, when I changed the servername
    1 from today, when I changed the server name again.
    What are these application passwords for and can I safely remove all but the last one? What are they for?

    I went ahead and remove them a month ago. So far, there don't seem to be any issues. As long as you double-triple-check that the hash-number in those "Mac OS X Server certificate management" keychains _aren't_ in the filename of any of the *.pem files in the /etc/certificates folder, you can delete those orphan keychains.

  • I recently ran monolingual and removed all but the intel-64 bit architectures.  Now my iphoto will not open.  Here's the message  that I get. Process:         iPhoto [3543] Path:            /Applications/iPhoto.app/Contents/MacOS/iPhoto Identifier:

    I recently ran monolingual and removed all but the intel-64 bit architectures.  Now my iphoto (along with Idvd, garage band, imovie) will not open.  Here is the message that I get.
    Process:         iPhoto [3543]
    Path:            /Applications/iPhoto.app/Contents/MacOS/iPhoto
    Identifier:      com.apple.iPhoto
    Version:         ??? (???)
    Build Info:      iPhotoProject-4750000~1
    Code Type:       X86 (Native)
    Parent Process:  launchd [109]
    Date/Time:       2011-06-10 21:48:59.821 -0500
    OS Version:      Mac OS X 10.6.7 (10J869)
    Report Version:  6
    Interval Since Last Report:          -4164908 sec
    Crashes Since Last Report:           8
    Per-App Crashes Since Last Report:   11
    Anonymous UUID:                      45357CCD-011B-482E-A2EA-CF42096F1321
    Exception Type:  EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000002, 0x0000000000000000
    Crashed Thread:  0
    Dyld Error Message:
      Library not loaded: /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow
      Referenced from: /Applications/iPhoto.app/Contents/MacOS/iPhoto
      Reason: no suitable image found.  Did find:
              /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow: mach-o, but wrong architecture
              /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow: mach-o, but wrong architecture
    Binary Images:
    0x8fe00000 - 0x8fe4162b  dyld 132.1 (???) <1C06ECD9-A2D7-BB10-AF50-0F2B598A7DEC> /usr/lib/dyld
    Model: iMac10,1, BootROM IM101.00CC.B00, 2 processors, Intel Core 2 Duo, 3.06 GHz, 4 GB, SMC 1.53f13
    Graphics: ATI Radeon HD 4670, ATI Radeon HD 4670, PCIe, 256 MB
    Memory Module: global_name
    AirPort: spairport_wireless_card_type_airport_extreme (0x168C, 0x8F), Atheros 9280: 2.1.14.5
    Bluetooth: Version 2.4.0f1, 2 service, 19 devices, 1 incoming serial ports
    Network Service: Built-in Ethernet, Ethernet, en0
    Serial ATA Device: ST31000528ASQ, 931.51 GB
    Serial ATA Device: OPTIARC DVD RW AD-5680H
    USB Device: USB2.0 Hub, 0x05e3  (Genesys Logic, Inc.), 0x0608, 0x24300000
    USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8502, 0x24400000
    USB Device: External HDD, 0x1058  (Western Digital Technologies, Inc.), 0x0901, 0x26400000
    USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 0x26500000
    USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x04500000
    USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x06100000
    USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8215, 0x06110000

    Please let me know when you find a fix. I did the same thing and have tried every suggestion I can find online. The message I get is...
    Process:         iPhoto [4991]
    Path:            /Applications/iPhoto.app/Contents/MacOS/iPhoto
    Identifier:      com.apple.iPhoto
    Version:         ??? (???)
    Build Info:      iPhotoProject-6070000~1
    Code Type:       X86 (Native)
    Parent Process:  launchd [142]
    Date/Time:       2011-06-13 23:39:38.485 +1200
    OS Version:      Mac OS X 10.6.7 (10J869)
    Report Version:  6
    Interval Since Last Report:          -1643976 sec
    Crashes Since Last Report:           35
    Per-App Crashes Since Last Report:   12
    Anonymous UUID:                      D4811036-EA8D-479D-8D9F-11E2FC8F6D4C
    Exception Type:  EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000002, 0x0000000000000000
    Crashed Thread:  0
    Dyld Error Message:
      Library not loaded: /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow
      Referenced from: /Applications/iPhoto.app/Contents/MacOS/iPhoto
      Reason: no suitable image found.  Did find:
              /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow: mach-o, but wrong architecture
              /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow: mach-o, but wrong architecture
    Binary Images:
    0x8fe00000 - 0x8fe4162b  dyld 132.1 (???) <1C06ECD9-A2D7-BB10-AF50-0F2B598A7DEC> /usr/lib/dyld
    Model: MacBookPro7,1, BootROM MBP71.0039.B0B, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.62f6
    Graphics: NVIDIA GeForce 320M, NVIDIA GeForce 320M, PCI, 256 MB
    Memory Module: global_name
    AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.10.131.36.9)
    Bluetooth: Version 2.4.0f1, 2 service, 19 devices, 1 incoming serial ports
    Network Service: AirPort, AirPort, en1
    Serial ATA Device: Hitachi HTS545025B9SA02, 232.89 GB
    Serial ATA Device: MATSHITADVD-R   UJ-898, 3.5 GB
    USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 0x26100000
    USB Device: Built-in iSight, 0x05ac  (Apple Inc.), 0x8507, 0x24600000
    USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0x06600000
    USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8213, 0x06610000
    USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0x06500000
    USB Device: Apple Internal Keyboard / Trackpad, 0x05ac  (Apple Inc.), 0x0236, 0x06300000
    I have reinstalled Mac OSX 10.6.3 and done the updates from there.
    I have reinstalled ilife 11 from disk and done the updates.
    I have deleted all the suggested files and then redone install and updates.
    I have tried just reinstalling iphoto and doing updates.
    Is there any way to get a replacement -  /Library/Frameworks/iLifeSlideshow.framework/Versions/A/iLifeSlideshow
    file with the right architecture?

  • My iPhoto 11, V 9.4.2, locks up/freezes when I attempt to empty the iPhoto trash bin.  Originally, I thought it was due to 800  files in the trash, however, I removed ALL but 5 photos from the trash and it continues to lock up.

    My iPhoto 11, V 9.4.2, locks up/freezes when I attempt to empty the iPhoto trash bin. 
    Originally, I thought it was due to 800+ files in the trash, however, I removed all but 5 photo files from the trash and it continues to lock up.  Inititally the "progress" bar would get to about 1/2 way and then it would stop and stall.  However, now the progress bar no longer shows a progress line it immediately freezes and locks up. Can anyone help? 

    You may have damaged the library - Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library
    LN

  • How can I clean a mailbox and remove all but the latest message in thread, and more...

    I am using Thunderbird version 24.6.0, for years I have been saving every email into a mailbox folder of a technical email alias I subscribe to.
    The folder now has over 12,000 emails and I am exceeding 700 MB. Is there an Addon or tool of any kind that allows me to automatically in one fell swoop delete all but the last message in a thread assuming all prior messages included all prior messages in thread, BUT here's the hitch, if someone responded out of order to a thread or did not include prior messages, their message should be saved since it will not appear in the prior string of messages.
    I can draw it out better than explain it, I want to save all responses to a thread, except those that are captured by the final message in a thread, or....
    | Re:- topic1 a. don't save because all included in "c"
    |- Re: topic1 b. don't save because all included in "c"
    |- Re:topic1 c. save
    | Re:- topic1 d. don't save because included in e.
    |- Re: topic1 e. save
    Thanks! ed

    I have no idea on how, but your file needs to exceed 4Gb before there will be any kind of issue (and the guys think they have removed that limit not anyway)
    Thunderbird will not move slowly or anything with lots of messages.

  • Write to Text File.vi Output file all but first line start with tab

    The attached PNG shows the code used to build up concatenated strings into a string array for the first four lines, thence to a string Array, to Spreadsheet String.vi and, finally, the use of Write to Text File.vi
    The lower right corner shows the result loaded into a spreadsheet. Note the 3 blank entries marked by a filled red rectangle. Examination of hidden characters shows there is a tab at the beginning of lines 2, 3 and 4.
    There is no tab shown in the code. How do those tabs get there? How do I stop them?
    I have tried with the option "Convert EOL" both on and off with no difference.
    The Help states that an OS-dependent EOL character is appended to each line. I can't imagine the Windows EOL character includes a tab.
    Solved!
    Go to Solution.
    Attachments:
    Tab Mystery.PNG ‏29 KB

    wildcatherder wrote:
    I am still puzzled as to why those additional tabs were added by Array to Spreadsheet String.  I'm holding in my hand a printout of an old LabVIEW 8 program with that construction, which is known to work properly.
    Makes complete sense when you look at your code.  You build a string, including an end-of-line character, and put that string into an array.  Then, when you run it through Array to Spreadsheet String, it puts a tab after every array element, and new line at the end of each row in the array.  The first element of your array contains a new line but Array to Spreadsheet String doesn't know about it; it still inserts a tab between that array element and the next one, giving you the tabs.

  • I am unable to burn CDs with songs recently purchased from itunes. No problem before. When I try to burn a playlist with new songs, I get the error message that "songs will not it on 1 audio CD". If I remove all songs except the new one, it will burn.

    I am unable to burn CD's with the last 4 songs I've purchased from the iTunes store. I can burn CD's from playlist using previously purchased songs with no problem. With a normal length playlist including 1 of the newly purchased songs, I get the message "songs will not fit on one CD". I can remove all but the new song and 1 other and the CD will burn. I have upgraded to the latest version of iTunes and still have the problem.

    I have that EXACT same problem! I have no idea what to do though, but it is very mucho frustrating. Let me know if you find out anything, and I will do the same.

  • Just registered second phone and sync to first which has removed all contacts photos etc. How do I register as a second phone but share music?

    Just registered a second phone and sync to first which has removed all contacts photos etc. How do I register as a second phone on the same PC
    but share music?

    Big Gilly wrote:
    Just registered a second phone and sync to first
    You can't sync from phone to phone so please clarify what you're referring to.

  • Recursively iterating over all child controls

    Hi All,
    I'm trying to recursively iterate over all child controls in my Flex 4 application, and I've been doing something like this to get the immediate children of a particular container:
    public static function getElements(parent:Object):Vector.<IVisualElement>{
         var result:Vector.<IVisualElement> = new Vector.<IVisualElement>();
         for(var i:int = 0; i < parent.numElements; i++){
              result.push(parent.getElementAt(i));
         return result;
    I can then call that function recursively.  It works--kinda.  The way it doesn't work is that if I call this object on the application object itself, it will only give me back elements that are visible in the current state.  As I move from one state to another, different elements are returned by my getElements method.
    So, is there are way I can find all child elements, whether or not they are visible in the current state?
      -Josh

    Hi Josh,
    So, I've come up with some quick code for you. However, I must add my disclaimers first:
    The code is incomplete in that it excludes children of children that don't use states, but includes children of children that are associated with states of the parent. I'm also definitely not an expert in how our states system works.
    I'm not sure what your use case for all of this is, but my best guess is that it would be better to find a different way to solve your problem than to go the route of introspecting states. It's a long and dirty road =).
    Other than that, I've attached the code for you. The meat of this is:
         *  Finds all elements in all states that use the states of the specified parent.
        public static function getAllElements(parent:UIComponent):Vector.<IVisualElement>
            var container:IVisualElementContainer = parent as IVisualElementContainer;
            if (!container)
                return new Vector.<IVisualElement>();
            var result:Vector.<IVisualElement> = getCurrentElements(container);
            var states:Array = parent.states;
            for each (var state:State in parent.states)
                for each (var addItems:AddItems in state.overrides)
                    var elt:IVisualElement = addItems.items as IVisualElement;
                    if (elt && !containsElement(result, elt))
                        result.push(elt);
            return result;
    This method takes the parent container (in my case, the application) and returns a vector of children elements that associate themselves with the states of this parent container. First, it grabs all the elements already created from the parent container. Next, it iterates over each state and then each AddItems of each state. The AddItems object contains the information and pointers to the specific element that will be "added" when the current state changes to that state. By calling addItems.items, we force the creation of the specific element which is returned to us. Now, we can use a simple containsElement() method to check for duplicates and build a list of elements that would be added to each of the states.
    Again, the code is finding all of the children of the provided parent in all of its parent's states; however, it also finds children of children that may be using the parent's states as well. But if the children of children are not using the parent's states then it will not be found (easily fixable if you recurse). In addition, knowing which elements belong to which container just from introspecting the State object is pretty complicated and involves understanding how addItems.apply() works.
    Anyway, I hope this helps you. I would be interested in hearing your use case since this code is pretty complicated. I'd like to see if I could help by finding a different approach for your problem.
    -Kevin

  • Is there a way to remove all email at once on iPad first generation?

    Is there a way to remove all email at once on iPad first generation?

    Issue does not apply to just first gen iPads, but all iOS devices. The only place in the native mail app that permits deleting en mass is the trash folder. In all other folders you must tap each message to select it before deleting. There may be alternate mail apps that include this function in the app store, but I have yet to find one.

  • Why is the itunes store removing some songs/albums here and there? First they removed all of the Monkey Majik albums, now they've deleted a album by Moonjam in the Mexico store. Im upset

    First they removed all of the Monkey Majik albums in the US Store, now they've deleted a album by Moonjam in the Mexico store.
    Im sorry, but im upset, very.
    Some of my friends think maybe it's because that certain album or two were no longer selling. And yet, there are other ones that
    literally have no reviews, no ratings, not one person buying a song from there, and yet, itunes is still hanging on to them. What's up
    with that.

    "ah, so It's really up to the artists/ Distributions people that decide what can be published or sold? "
    Yes.

  • How to reduce the version of a pdf 1.7 to 1.5 & how to remove all the embedded xml form ?

    Hi Team,
        I am using adobe acrobat x pro. I have a pdf file of version 1.7 which showing embedded xml forms. I tried to remove all the 'embedded xml form' by  using Adobe Live cycle Designer ES2.  Then i tried to reduce the version by using Adobe acrobat x pro but it's still showing that there are some 'embedded xml form' for which it's not allowing me to reduce the vesion of pdf file in Adobe Acrobat x pro and also i want reduce the version of the pdf 1.7 to 1.5. Can you please guide me the step to reduce the pdf file version and how to remove the embedded xml form from the pdf file ?

    If the PDF is the same one from the link in your post here:
    http://forums.adobe.com/thread/1174643
    That PDF being protected may have something to do with why you cannot do what you'd like to.
    Be well...

  • Remove ALL xml

    My company is changing processes away from an xml based workflow, so we have hundreds of InDesign files that need to have the xml removed. I'm writing a script that will do it automatically, but I'm having problems untagging all of the text. Most files have a structure like this:
    My starting script here:
    /*REMOVE TAGS*/
    myDoc.xmlElements[0].xmlElements.everyItem().untag();
    try{
    myDoc.xmlInstructions[0].remove();
    catch(e){};
    myDoc.deleteUnusedTags();
    var myRoot = myDoc.xmlTags[0].name;
    $.writeln(myRoot);
    myDoc.xmlTags.itemByName(myRoot).name = "Root";
    /*END REMOVE TAGS*/
    gives me this result:
    I need help untagging the text leftover in the 'Root' tag so that my final result is this:
    Any advice?

    @T-Stevens – we already had that solved here.
    See the following:
    Re: "Untag Frame" menu action is invalid [CS5 Win XP]
    Here the "long" version:
    Hans Haesler at www.hilfdirselbst.ch once wrote the following snippet:
    app.documents[0].xmlElements[0].xmlElements.everyItem().untag();
    The root element might be left over now.
    Gregor Fellenz did the following "hack" to get rid of it as well:
    var tempRect = app.documents[0].rectangles.add();
    tempRect.markup(app.documents[0].xmlElements[0]);
    tempRect.remove();
    Don't know, if that will work for you…
    Also see the following thread in German about it:
    <Root>-Tag von Rahmen entfernen - Adobe InDesign Skriptwerkstatt - HilfDirSelbst.ch - Forum
    Also the alternative solution with a script menu action by Hans Haesler:
    <Root>-Tag von Rahmen entfernen - Adobe InDesign Skriptwerkstatt - HilfDirSelbst.ch - Forum
    Uwe

  • First sync with bold removed all numbers

    I am helping a friend and I am trying to get some answers about OS and such but...  Anyway, the first time she synced her bold to her mac using the desktop sofware, it did not go two ways.  it removed all of her contacts from the blackberry and replaced them with the ones from the mac.  she did click two way.  I am a pc user so I am unfamiliar.  We did follow the manual directions and turned isync on and such.  Any help would be appreciated.  I will try to get os info when she gets back to me.

    same thing happened to me!!! please help!

Maybe you are looking for

  • Configure myfaces 1.2.7 problem on JDeveloper 11 and Weblogic 10.3 server

    Hi all, 1st I'm not sure if that the right place or not to send this post(if not please accept my apologize) I'd like to use myfaces 1.2.7 implementation instead of the JSF Library provided by Jdeveloper 11 That's the Jar files I used :- myfaces-api-

  • 5800 XM camera issue

    Hi I just want to ask quastion I have 5800XM and it is soo good.However, 5800 camera is bad in some phones but it is very good in others, why is that??  can I fix my camera or go to nokia to change it?? if anyone can help me to improve my camera I wi

  • "undiagnosed_problem" errors from fmd after installing 2nd CPU

    Hi everyone, [Disclaimer: I am not a professional Solaris sysadmin] I have an HP Proliant DL145 g2 server. This is an AMD Opteron box running Sol10 x86. I recently installed a second cpu in this machine. Now, the fault manger daemon is logging the fo

  • Getting the value of a html:text property in javascript function

    Hi all, I am using struts framework and I need to get a value in a textfield both in java part and javascript part <td><html:text property="identityNumber"> </td> I dont know how can I reach the value user entered in that field in the javascript func

  • Photoshop wont start. (CS6 / Win 8.1)

    Help! I cant open photoshop. It will load, but by the time i click 'File' the whole application will close. What's wrong? Been trying to search for a solution but cant seem to find one. Or maybe I'm too lost. -E