Delete xml element not used in document

Hi,
If you have a number of texts tagged with an xml element and then delete the text, the element still exist in the structure.
You can see the element still connected to a text, by the blue diamond on the element symbol.
But i want do delete the elements that have no connection to texts, but cant find the right property to look for.
In Java script CS4.
Anyone knows?
/Mikael

If the (text) element is unplaced, its parentStory will be an XmlStory rather than a Story.
So try:
var elements = app.activeDocument.xmlElements[0].xmlElements.everyItem().getElements();
for (var i = elements.length - 1;i >= 0;i--){
    if(elements[i].parentStory.constructor.name === "XmlStory"){
        elements[i].remove();
This is untested. If you have tagged graphics frames it will need to be modified to not error on those.
Jeff

Similar Messages

  • Deleting XML element in ABAP mapping

    hi All
    I Have I huge xml filen that has to go to an Idoc , but I only want to use the header data.
    is there a way of deleting the unwanted xml elements and their children elements in ABAP mapping.
    Thanks.

    Hi Ravi and all
    Actually I did as you said, but I get this error.
    <Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    XMLParser: Prefix 'ns1' is not mapped to a namespace(:main:, row:177, col:25)
    This position 177 , is the element that is not needed , so I thought if I can delete it , I can get rid of this error and move forward.
    May be you have antoher suggestion to get rid of this error.
    Thank you.

  • Missing XML Element when using asset from library

    This is not really a scripting question but I seem to be unable to find any regular ID forum and it has something to do with a scripting workflow I established for a customer.
    A script places an asset from a library onto a document and then (amongst other things) imports some XML file.
    The asset in the library consists of a number of textframes and has the structure e.g.:
    article
    box
    box
    Now the customer needs new templates (that is assets in the library) and we cannot produce them anymore. It seems that as of CS 3 5.0.4 Adobe changed the behavior of the library. Dragging e.g. two box-tagged boxes with an article parent XML into the library leads to an asset without the article element. Can someone confirm this? And more important is there a reason to it? Or is there a way to configure the behavior?
    I guess I could create a parent xml element by script after placing the element but then I would need to redo all existing libraries.
    Thank you,
    Ralf

    while( testIterator.hasNext() ) {
       Element testElement = (Element)testIterator.next();
       String code = testElement.getChildTextTrim("code");
        if( null == code ) {
               continue;
       String analysis= testElement.getChildTextTrim("analysis");
       //same for description
    }

  • AFAB asking for new cost elements not used before.

    AFAB returns error indicating a range of cost elements that was not existing in the previous system and in the new system (ECC6) as well.
    I like to know why this error when it is not being used and how to rectify to allow AFAB.

    Hi,
    Cost elements does not exsist so there is no question of validity in master data.
    It is asking to create cost elements. So, i want to know why the system is asking or from where it is picking up?
    We have not used this cost elements before.

  • How do I set a different folder than the Windows MyDocuments/Downloads folder? I do not use 'My Documents' at all, all my saved files go to other hard drives for storage, and I do not want to bother with the My Docs route. I used to have downloads set to

    I want to set a different folder from the My Documents/Downloads folder for Firefox to put everything I download, like I used to have it. I recently rebuilt my computer and reinstalled everything from WinXP to security software to Firefox, and I cannot find any options anywhere to set a different folder like I used to have it... with the same software, other than it being a newer iteration of Ff. So tell me, am I losing my mind so bad that I just can't remember how I did it before, or have things changed so much that what I want is no longer possible? Please, someone tell me how to set it to do what I want, I can't stand to have what I do on my computer dictated by programmers who only think that they know what people want. If that sounds a little angry, I apologize with the disclaimer that I suffer from Post Traumatic Stress Disorder and therefore cannot handle frustration... and this kind of thing frustrates me to the point of rage.

    Tools > Options - General tab = Downloads
    Set your preferences there.

  • Open XML Forms not using KM

    Hi experts,
    I have the following request:
    Place a link in the Portal that displays a custom XML Form document to fill in.
    By now I have always filled in new XML Forms documents by accessing KM and selecting 'New > Form > <custom form>'.
    Now I need to access a XML Form by clicking a link in Portal (without accessing KM). Is there any special iView already created for this? Is this possible in any other way?
    Many thanks in advenced and regards
    Stella

    Hi,
    You can create a KMnavigation iView and change the following propertie s
    Layout set = NewsExplorer
    folder =News
    and create iView.
    Assign this Iview to the role and role to a user.So when user clieks on role he can create  news .
    Hope it helps.
    Reward suitable points.

  • Delete xml element

    I have a query here
    SELECT XMLELEMENT("emp",CHR(10),chr(9),XMLELEMENT("empno",XMLATTRIBUTES(EMPNO AS "value"),CHR(10),chr(9),null),CHR(10)) FROM EMP
    WHERE EMPNO=7369
    the output is
    <emp> <empnovalue="7369">
    </empno>
    </emp>
    here I dont want to show </empno>
    my output shold be like this
    <emp> <empnovalue="7369">
    </emp>
    Please help me.
    Thanks.

    my output shold be like this
    <emp>
    <empno value="7369"/>
    </emp>
    SQL> SELECT XMLELEMENT ("emp", XMLFOREST (XMLELEMENT ("empno", xmlattributes (empno "value")) "empno", NULL AS "empno").EXTRACT ('empno/*')).extract('*') xml
    FROM emp
    WHERE empno = 7369
    XML                                        
    <emp>                                      
      <empno value="7369"/>                    
    </emp>                                     
    1 row selected.

  • Can I delete ALL photo's not used in Albums?

    Hi,
    So, my iPhoto Library has become too big to manage. about 40 gigs. My albums are filled with my selected photos. Is there I way I can delete everything else, not used in an album? Do I have to click on the photo tab and delete manually?
    I hate to burn all the albums, delete everything, then re-import.
    Anyone use Media 100 Editing software? There is a great feature that allows you to remove all media not being used in a bin or project. I'm wondering if there is something similar in iPhoto.
    Any suggestions are welcome.
    Thanks
    Ethan-

    Try creating a smart album with the following criteria: *+Album is not any+*. Then apply a new keyword to those photos in the smart album.
    Next check your other albums to see if that keyword appears in any of them. If not then you can be assured that deleting the photos in the smart album will leave only those in the other album. Of course to be on the safe side backup you library before deleting the photos.
    Also don't delete more than about 100 photos at a time. iPhoto has a know disposition to choke when trying to delete large number of photos at one time.
    OT

  • How to delete xml tags Urgent

    on release function i am inserting this value
    "(&-box*&", "&*box-&
    " in to my text box,
    in text box will display like this (squarebox), when i am
    trying to delete
    squarebox ,
    box deleting but
    (&-box*&", "&*box-&
    these xml elements are showing , what i have to
    do ? it has to delete,
    it amy have multipule box in my equation. how do delete xml
    elements in this case, this is my xml code. how to delete? any one
    can help me?

    Then you should provide more details on what you want this new script should do.
    To "delete XML tags in already tagged text", all you need is use the "untag" command on an XML Element. But how would the script "know" what XML Element should be untagged?
    Disclaimer: This reply is in no way enforceable, legally binding, a promise or contract, an agreement (written, verbal, or otherwise), a commitment, obligation, or free or paid-for offer of any kind to further help, guide, aid, tip, or not hinder you, or contribute to, correct, investigate, comment on or assist with any existing, forthcoming, or planned project.

  • Namespace in xml element

    I have an xml file tagged with namespaces:
    for example, ce:section, ce:para
    i just trying to collect the 'ce:floats' xml nodes by using the following code:
    //Defining the Namespace in the array of arrays of 2 strings
    Dim NmSpArr(,) As String = {{"sb", "http://www.elsevier.com/xml/common/struct-bib/dtd"}, {"cl", "http://xml.cengage-learning.com/cendoc-core"}, {"ce", "http://www.elsevier.com/xml/common/dtd"}, {"aid", "http://ns.adobe.com/AdobeInDesign/4.0/"}, {"aid5", "http://ns.adobe.com/AdobeInDesign/5.0/"}, {"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"}, {"xmlns:mml", "http://www.w3.org/1998/Math/MathML"}, {"xmlns:xlink", "http://www.w3.org/1999/xlink"}}
    //Trying to collect the 'ce:floats'
    Dim obj As InDesign.Objects = IndDoc.XMLElements(1).EvaluateXPathExpression("//ce:floats", NmSpArr)
    ID CS4
    Vb.net
    Above code always returning 0 as count. It seems there is problem with the xml namespaces definition.
    Any help would be greately appreciated.
    Regards,
    Suresh

    Suresh:
    Is there anyone know any alternative methods to collect the xml nodes with namespaces?
    Again, I wrote:
    But it shouldn't be too much work to just traverse the tree.
    Here's an example in JavaScript. It should be easy to translate it into VB. Of course all you need is the traverse() function -- the rest is just examples and test cases:
    (function() {
      var
        x = app.activeDocument.xmlElements[0],
        star, all, floats, cefloats, anyfloats;
        function traverse(t, p) {
            var r = [], i;
            if (p(t)) {
                r = r.concat(t);
            for (i=0; i<t.xmlElements.length; i++) {
                r = r.concat (traverse(t.xmlElements[i], p));
            return r;
        function dumplist(l) {
            var i,
                rv = [];
            rv.push("has "+l.length+" elements:");
            for (i=0; i<l.length; i++) {
                rv.push("  "+i+"\t"+l[i].toSpecifier()+
                    "\t"+l[i].markupTag.name);
            return rv.join("\n");
      star = x.evaluateXPathExpression("*");
      all = traverse(x,
          function() { return true; }
      floats = traverse(x,
           function(n) { return n.markupTag.name==="float"; }
      cefloats = traverse(x,
          function(n) { return n.markupTag.name==="ce:float"; }
      anyfloats = traverse(x,
          function(n) { return n.markupTag.name.match(/float$/); }
      $.writeln("star: "+dumplist(star));
      $.writeln("all "+dumplist(all));
      $.writeln("floats "+dumplist(floats));
      $.writeln("cefloats "+dumplist(cefloats));
      $.writeln("anyfloats "+dumplist(anyfloats));
    So, if you run this on a document with an XML schema like this:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Root>
      <ce:float>A</ce:float>
      <ce:float>B</ce:float>
      <float>AC</float>
      <float>Ad</float>
      <ce:float>Af</ce:float>
      <div>
        <ce:float>Ai</ce:float>
        <float>Ag</float>
      </div>
    </Root>
    It gives you this output:
    star: has 3 elements:
      0     /document[@id=1]/XML-element[@id=2]/XML-element[@id=5]     float
      1     /document[@id=1]/XML-element[@id=2]/XML-element[@id=6]     float
      2     /document[@id=1]/XML-element[@id=2]/XML-element[@id=11]     div
    all has 9 elements:
      0     /document[@id=1]/XML-element[0]     Root
      1     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
      2     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
      3     /document[@id=1]/XML-element[0]/XML-element[2]     float
      4     /document[@id=1]/XML-element[0]/XML-element[3]     float
      5     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
      6     /document[@id=1]/XML-element[0]/XML-element[5]     div
      7     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
      8     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float
    floats has 3 elements:
      0     /document[@id=1]/XML-element[0]/XML-element[2]     float
      1     /document[@id=1]/XML-element[0]/XML-element[3]     float
      2     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float
    cefloats has 4 elements:
      0     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
      1     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
      2     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
      3     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
    anyfloats has 7 elements:
      0     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
      1     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
      2     /document[@id=1]/XML-element[0]/XML-element[2]     float
      3     /document[@id=1]/XML-element[0]/XML-element[3]     float
      4     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
      5     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
      6     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float

  • CS3 / javascript / Creating anchor frame and placing xml element

    Hi All,
    I have a problem with creating anchor frame, that is
    Actually i have created anchor frame, but it is not allowing to place the xml element, it shows "inline frame xml elements not allowed" some thing like this.
    I have handled anchor frame type is "custom" but it shows "inline frame".
    Any of you got better idea about this.
    regards,
    sudar.

    I believe this has to do with you doing a placeXML, where the XML contents does not match the tagged frames in the document.
    Again i'm not sure, but i dont think this has to do with what kind of frame you are placing into(inline or custom anchor) rather if your tagged frames and XML match up.
    Perhaps this link will help:
    http://forums.adobe.com/message/1111773

  • I need to find all XML elements and add a line break to the text of each of them

    I need to find all XML elements and add a line break to the text of each of them.
    Is this possible with a script?

    I need to go from this ...
    to this...
    but looking for the XML elements (not paragraphs) and then adding text ...
    Thanks for your attention !!!

  • When I try to delete page(s) from a PDF document I created, I geth the following message: "One or more pages are in use and could not be deleted." Any suggestions?

    When I try to delete page(s) from a PDF document I created, I geth the following message: "One or more pages are in use and could not be deleted." Any suggestions?

    I sent an email to TerraGo Support and they sent the following response: "This has bug has been discovered and our development team is quickly creating a patch to resolve the problem. The patch should be available within a week or two. For your reference, the bug number assigned to this case is: 3620. Check back in about two weeks and hopefully the patch will be available. Again, I apologize for the inconvenience."

  • Proper use of normalize(); XML spaces not removed

    Ok so I was up till 3 AM trying to figure out why normalize is not removing white space. I have nothing left to normalize() except my brain. Any help would be appreciated.
    Code snippit to remove children & parents
    if( !elemSave ){
    while( ((Element) n).hasChildNodes() ) {
    ((Element) n).removeChild( ((Element) n).getLastChild() );
    ((Element) n).getParentNode().normalize();
    //have tried normalize here doesnt close the spaces
    ((Element) n).getParentNode().removeChild((Element) n);
    //tried normalize here doesnt close the spaces
    document.normalize();
    return document;
    ------- Resulting XML ---------
    <?xml version="1.0" encoding="UTF-8"?>
    <Entity createddate="6/19/08" defaultrole="CONTR_CAND" id="93023" updateddate="2/6/09">
    <Role>CONTR_CAND</Role>
    <Property bisuniqueid="6172" name="SKILLS" occurrence="1">
    <Attribute name="SKILL" sqldatatype="NUMERIC"/>
    <Attribute name="YEAR_EXP" sqldatatype="NUMERIC"/>
    <Attribute name="LEVEL" sqldatatype="NUMERIC"/>
    </Property>
    <Property bisuniqueid="4385" name="JOB_CAT" occurrence="1">
    <Attribute name="JOB_CATEGORY" sqldatatype="NUMERIC">8253425</Attribute>
    </Property>
    </Entity>

    find it odd that you can delete the child nodes of an Element and there is no space <Property name="something" /> but when you delete the Element that held the children you come up with an empty space.I have no clue what you're saying here. The whitespace around an element is held as a peer of the element, not its child.
    Thanks for the idea kdgregory but I would rather use JDK. The project is open source. You could simply copy the relevant method into your own code (although the Apache license requires you to acknowledge the source):
        public static void removeEmptyTextRecursive(Element elem)
            NodeList children = elem.getChildNodes();
            for (int ii = children.getLength() - 1 ; ii >= 0 ; ii--)
                Node child = children.item(ii);
                switch (child.getNodeType())
                    case Node.ELEMENT_NODE :
                        removeEmptyTextRecursive((Element)child);
                        break;
                    case Node.CDATA_SECTION_NODE :
                    case Node.TEXT_NODE :
                        if (StringUtils.isBlank(child.getNodeValue()))
                            elem.removeChild(child);
                        break;
                    default :
                        // do nothing
        }There is still a dependency on Jakarta Commons-Lang StringUtils, but I'll leave the copying of that method up to you.
    ... although you really should start using utility libraries -- they exist because other people have run into the same issues.

  • How can we get the reference of XML element on frame as soon as frame is created in Document?

    Hi,
    When ever we copy any text/table cells from any frame, and paste it directly on page, A new Frame is created and the pasted text is placed inside that frame.
    Now to capture this frame creation, We have two possible solutions:
    1) Attach Observer on Document 'kDocBoss' on IID_IHIERARCHY_DOCUMENT and it will notify on frame creation in update function.
    2) Notification event on new story creation.
    Now, I need to perform some changes in the newly created table, for example:
    a)  Need to delete XML tags from newly created frame
    b)  Need to perform action on table cells if any in the created frame.
    But the problem is, when the event comes, I can access basic properties of frame like it's name, type etc, but it does not give me the
    XML element on frame or tables in frame until the event is com pleat.
    I know it's quite a specif requirement, but I guess many of you might have faced these kind of challenges, while processing the event.
    Does any one has any idea how I can get the reference of XML element on frame as soon as it is created?

    Hi Kapoor,
    please give also others a chance, and excuse that I get up late on vacation ;-)
    Anyway, I'd keep the story creation responder to recognize the copy, then combine it with an observer on the backing xml story to catch the associated XML element which is created there. Something like below:
    UIDRef xmlStoryRef = Utils<IXMLUtils>()->GetBackingStore(doc);
    InterfacePtr<ISubject> subject ( xmlStoryRef,IID_ISUBJECT );
    subject->AttachObserver(observer,IID_IIDXMLELEMENT,observer->GetAttachIID());

Maybe you are looking for

  • ITunes crashes while installing...

    Hi couple of months ago I purchased this new PC and installed iTunes on this, also purchased a new laptop HP Pavillon 4000 series with which iTunes came preinstalled. Now some time back I used system restore on both (PC + Laptop) and when after it I

  • File names are not being created correctly!!

    Problem I have, and it seems to be an issue with iTunes in Windows and not Mac or in Windows Media Player for that matter. Anyway, the problem is that the files are not being written as they are displayed in the Album Data in iTunes itself. It just a

  • Need help on recovery

    Hello All, We have a datagurad implmentated system. Yesterday due to some reasons Primary server crashed( it will take 1 or 2 day get back the server with filesystem) . Now we have secondary system at diffrent location which is still up and running.

  • CS6 photoshop message 'could not load the fast core routines module because the file was not found'

    my CS6 photoshop is giving me the message 'could not load the fast core routines module because the file was not found'. this started happening after i used a trial of photoshop CC and decided not to stay with it.  my photoshop is part of my CS6 suit

  • FB01 or FB60

    Hi all, While posting invoice i.e FB01,fb60 and FB70 with tax code getting below dump and without tax code we are not getting dump. untime Errors         SAPSQL_INVALID_FIELDNAME xcept.                CX_SY_DYNAMIC_OSQL_SEMANTICS ate and Time