How to add content in the xml element?

I need to insert a word sqrt (plain text without tags) in the xml element of m:msqrt as below:

enter image description here

I tried,

     

var path = (app.activeDocument.fullName.parent.fsName) m:System.NET.SocketAddress.ToString () replace (/ \ / g, ' /'); document path (sample.indd) active

var xmlPath = (app.activeDocument.fullName.parent.fsName) m:System.NET.SocketAddress.ToString (.replace(/\\/g, '/')) + "" / with_aid2.xml ";"

xmlFile = file (xmlPath);

{if (xmlFile.Exists)}

xmlFile.open ();

var myString = xmlFile.read ();

xmlFile.close ();

myXml = new XML ();

myXml = XML (myString);

var msqrtCount = myXml.xpath("//m:msqrt");

} else {alert (xmlPath + "does not exist!") ;}}

for (var i = 0; i < msqrtCount.length (); i ++) {}

var added = msqrtCount [i];

added.contents = "sqrt";

}

I get an error indicates the invalid content property.

Try this,

var myDoc = app.activeDocument;
mySqrtTag(myDoc)
function mySqrtTag(elm)
{
    for (var i = 0; i < elm.xmlElements.length; i++)
    {
        if(elm.xmlElements[i].markupTag.name.toString() == "m:msqrt")
        {
            elm.xmlElements[i].insertionPoints[0].contents = "sqrt";
        }
        mySqrtTag(elm.xmlElements[i]);
    }
}

Tags: InDesign

Similar Questions

  • How to separate the content of the XML element

    Hi all

    How can we separate content of the XML element in two strings, where each string will be copied to new variables.

    For ex:
    The entry that I get is

    C:/documents/sharedFiles/Apple.PDF < XmLElement > < / XMLElement >

    now I want to break the content into two parts as

    < yyyy > C:/documents/sharedFiles / < / aaaaa >
    Apple.PDF < bath > < / bath > (I want to separate the file name string)

    and now I want to copy it in two other variables. How can I achieve this in BPEL. Appreciate your help.

    Thank you

    Published by: kameshb on March 25, 2013 11:16

    Hi Philippe,.

    I tried this on a simple XSL and achieve the desired results:

    Entry:
    ------------

    C:/test/dummy/post/test.PDF










    It will be useful.

    Thank you
    Deepak.

  • How to add content to the top of a page - not a header

    I'll put up a blog I'll add new post to.  I put a small introductory text and the image of all 32 Articles on the blog page.  These texts of presentation will be link to full blog on a subpage.  When I want to add a new blog, I want to do it at the top of the page - how can I do this without lag and get off all the small presentation texts.  It is easy to add at the bottom, but I would like the new blogs to appear at the top of the page.

    Unfortunately, you will have to select all your previous posts and move them down at once.

  • How to add subitems inside the xml file

    Hello

    This is the result I get in EM. Now, I want to add all three IncidentID and want to store in a variable. I used concat option, but it's not adding all the incidentID. How can I do?

    < HolxSrEventData >

    < incidentId > 2445030 < / incidentId >

    < > 55730 Parisby < / Parisby >

    < creationDate > 2013-01-22T 03: 46:23.000 - 05:00 < / creationDate >

    < processedFlag > Y < / processedFlag >

    < dateProcessed xsi: Nil = "true" / >

    < errorRemark > new entry < / errorRemark >

    < holxSrEventDataCollection / >

    < / HolxSrEventData >

    < HolxSrEventData >

    < incidentId > 2445030 < / incidentId >

    < > 55730 Parisby < / Parisby >

    < creationDate > 2013-01-22T 03: 46:23.000 - 05:00 < / creationDate >

    < processedFlag > Y < / processedFlag >

    < dateProcessed xsi: Nil = "true" / >

    < errorRemark > new entry < / errorRemark >

    < holxSrEventDataCollection / >

    < / HolxSrEventData >

    < HolxSrEventData >

    < incidentId > 2445030 < / incidentId >

    < > 55730 Parisby < / Parisby >

    < creationDate > 2013-01-22T 03: 46:23.000 - 05:00 < / creationDate >

    < processedFlag > Y < / processedFlag >

    < dateProcessed xsi: Nil = "true" / >

    < errorRemark > new entry < / errorRemark >

    < holxSrEventDataCollection / >

    < / HolxSrEventData >

    < / HolxSrEventDataCollection >

    Thank you

    Hello

    string-join is a standard xpath function... Oracle implements the function, but is not in the Mapper/wizards... It should be used in a transformation XSLT or BPEL 2.0...
    http://www.w3schools.com/XPath/xpath_functions.asp#string

    This transfer XSLT works, but you will lose the design view...

    
    
    
    
    
    

    I hope this helps...

    See you soon,.
    Vlad

  • How to add events to the array elements?

    Hello.

    I have the table with 5 boxes.

    I show as boxes on the stage that + having shown that it is random.

    Now, I want to add events to this boxes.

    For example if I click for box1 I have to go to "p4", if I click to other boxes that I have to go to "p3".

    I'm trying to do the same thing as for the buttons, but its does not work:

    classNames[0].addEventListener(MouseEvent.CLICK, goCorrect);
    function goCorrect(event:MouseEvent):void {
         trace("p4");
         gotoAndStop('p4');
    }
    
    classNames[1].addEventListener(MouseEvent.CLICK, goWrong);
    function goWrong(event:MouseEvent):void {
         trace("p3");
         gotoAndStop('p3');
    }
    

    All the code in the code here:

    var classNames:Array=["box1","box2","box3","box4","box5"];
    var boxesList:Array=[];
    var ClassRef:Class;
    
    for (var i:int = 0; i < classNames.length; i++) {
         ClassRef=Class(getDefinitionByName(classNames[i]));
         boxesList[i] = new ClassRef();
         addChild(boxesList[i]);
    }
    
    var currentBox:MovieClip;
    
    
    var nextX:Number=0;
    for (var iii:int = 0; iii < classNames.length; iii++) {
         currentBox=boxesList[iii];
         currentBox.x=nextX;
         nextX+=currentBox.width;
    }
    
    
    for (iii= 0; iii < 1*boxesList.length; iii++) {
         var pos1:int = (Math.random()*1000) %boxesList.length;
         var pos2:int = (Math.random()*1000) %boxesList.length;
    
         if (pos1!=pos2) {
              var temp:int=boxesList[pos1].x;
              boxesList[pos1].x=boxesList[pos2].x;
              boxesList[pos2].x=temp;
         }
    }
    
    myBox1.visible=false;
    
    
    classNames[0].addEventListener(MouseEvent.CLICK, goCorrect);
    function goCorrect(event:MouseEvent):void {
         trace("p4");
         gotoAndStop('p4');
    }
    
    classNames[1].addEventListener(MouseEvent.CLICK, goWrong);
    function goWrong(event:MouseEvent):void {
         trace("p3");
         gotoAndStop('p3');
    }
    //box1.useHandCursor=true;
    

    You cannot add event listeners to the objects that send events. Generally speaking, an object that you want to send events should extend the EventDispatcher class.

    In your case, you add event listener for the classNames group members that are strings. String not to send events. So, you have to add listeners to events for objects that you instantiate while loop if classNames - these items are (I presume that these are instances of MovieClip, which stretches from EventDispatcher). Therefore, in your case, you can do the following:

    MovieClip(boxesList[0]).addEventListener(MouseEvent.CLICK, goCorrect);function goCorrect(event:MouseEvent):void {     trace("p4");     gotoAndStop('p4');}
    
    MovieClip(boxesList[1]).addEventListener(MouseEvent.CLICK, goWrong);function goWrong(event:MouseEvent):void {     trace("p3");     gotoAndStop('p3');}
    
  • How to pass the content of an xml element in the text frame in inDesign Script

    var XMLFile = File.openDialog ("select XML Files... ») ;

    var doc = app.activeDocument;

    If (!) App.Documents.Length)

    {alert ("ERROR: Document not opened");}

    return;

    }

    doc.importXML (XMLFile);

    var firstFigureNode = doc.xmlElements [0] .xmlElements [1] .xmlElements [0];

    var lableNode = firstFigureNode.xmlElements [0];

    var lableNodeText = lableNode.contents;

    myFrame var = doc.textFrames.add ({geometricBounds: [-13, 13, 3, -3]});

    lableNodeText.move (LocationOptions.AFTER, myFrame.texts [0]);

    ========================================================

    My requirement is: == > > move the content of an xml element in the text by inDesign Script block, but XML InDesign file Structure should not be change & data in the XML Structure should remain as it was before...

    I tried to code above, but it does not work...

    Please can someone help me in solving this problem...

    It does not work correctly...

    It moves firstFigureNode in myFrame...

    firstFigureNode.placeXML (myFrame);

    ===>> For Apple Script try below Code ===>>

    myFrame markup using firstFigureNode

  • I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    Hello

    Can the code below is useful for you, but I do not know how to sort.

    Change the tag based on your employment application.

  • How can I save the references to the elements of the xml elements page?

    Hello

    I am trying to add coordinates of the page elements to their associated as xml attributes xml elements.

    I can easily create xml help items

    myDocument.mapStylesToXMLTags ();

    Now, I want to browse the xml document and find details of each element of the associated page and then add them in the corresponding as attributes xml node.

    In other words, I'm trying a code (assuming that all the nodes as children of the root for simplicity) as follows:

    for (var i = 0; i < myRootXMLElement.xmlElements.length; i ++) {}

    var myElement = myRootXMLElement.xmlElements.item (i);

    var myElementsPageItem = * did not find a reference of function / correct documents *.

    var myBounds = myElementsPageItem.visibleBounds;

    addORupdate (myElement, "y1", myBounds [0]);

    addORupdate (myElement, ' x 1', myBounds [1] ");

    addORupdate (myElement, "y2", myBounds [2]);

    addORupdate (myElement, ' x 2', myBounds [3] ");

    }

    In my example of document all the xml that is created by mapStylesToXMLTags() are history of type.

    So I need a way to refer to the corresponding (or rectangle) page element of the history so that I can add information about contact information item xml as attributes.

    Thank you very much...

    myElement.xmlContent.parentTextFrames was not defined in the xml document that is generated by mapStylesToXMLTags()

    After some research the object model, I found my data in

    myElement.xmlContent.textContainers [0]

    Thank you

    Halin

  • Loop through all of the xml elements

    How do I loop over all xml tagged in a story? I created a reference to the xml elements of the story I want to like this:

    var xmlStory = myDoc.xmlElements[0].xmlElements[0];
    

    In this structure, I have items < v > 10 / < v >, which I want to change of < id v '10' = > 10 / < v >. I want to do in the InDesign scripting and not with XSL export because of workflow, I plan. I know I can loop on children in the structure like this:

    for(var i=0;i<xmlStory.xmlElements.length;i++){
                        if(xmlStory.xmlElements[i].markupTag.name == "v"){
                                  xmlStory.xmlElements[i].xmlAttributes.add("id", xmlStory.xmlElements[i].contents);
                       }
             }
    

    This works very well for the first level, but I want to find all elements with the tag '< v >. These tags can appear at any level in the structure. How can I make sure that all of them are included and not just the first elements of the child of the element of the story?

    Try this,

    #target inDesign;

    var doc = app.activeDocument;
    xmlTag var = doc.xmlElements [0];
    var vTag = xmlTag.evaluateXPathExpression("//v")
    for (var i = 0; i)<>
    {
    Try
    {
    vTag [i].xmlAttributes.add ("id", vTag [i].xmlContent.contents)
    }
    {catch (e)}
    }

  • XML: contents.replace () destroyed XML elements inside

    Hello

    I wrote a script XML rule where all the < ul > < li > is mapped to a paragraph style that uses bulleted lists. It is possible that returns occur inside the < li > elements. Before you go through the items and by applying styles with a script rule, I tried to change the return (\r) of returns (\n) cycling through all the < li > with this code:

    _node.contents = _node.contents.replace(/\r/g, '\n');  //change all returns inside <usp><li> to newline
    

    But I realized that, when there are other XML elements (for example < em > or < strong >) inside the < li >, these elements have been killed by my call of. replace().

    So my question: How can I reach evolution \r's to \n's and keep inside XML structure?

    Thanks in advance

    Tobias

    I did it with this chiseled script - function grep with emphasis on the XML element - executed after that all XML was processed and placed in the document:

      // change \r to \n in usp's li's
      app.findGrepPreferences = NothingEnum.NOTHING; app.changeGrepPreferences = NothingEnum.NOTHING;
      var _root = _dok.xmlElements[0];
      var _nodeList = _root.evaluateXPathExpression("//li");
      app.findGrepPreferences.findWhat = "\\r"; app.changeGrepPreferences.changeTo = "\\n";
        for ( i = 0; i < _nodeList.length; i++ ) {
            var _node = _nodeList[i];
            if ( _node.contents != "" ) {
                _node.changeGrep();
            }
        }
      app.findGrepPreferences = NothingEnum.NOTHING; app.changeGrepPreferences = NothingEnum.NOTHING;
    

    It works perfectly. Any other suggestions?

    Thank you

    Tobias

  • Create the XML element for the cell in the chart CC2015

    Hello world

    I am currently working with the xml element.

    And I want to create xml, table cell element.

    For now, I can create xml for the graphic cell by select graphic image of that cell, and then call the AutoTag() function.

    But I want to create an xml element of a chart without selected cell.

    I found the function () Utils < IXMLElementCommands >-> CreateElement()

    but it doesn't seem to work with a graphic table cell structure.

    Does anyone know how to do?

    Thanks in advance.

    Try,

    InterfacePtr cellContent (tableModel-> QueryCellContentBoss (gridAddress));

    if(cellContent == Nil) {}

    break;

    }

    InterfacePtr cellXMLReferenceData (cellContent, UseDefaultIID());

    {if(!cellXMLReferenceData)}

    break;

    }

    XMLReference cellXMLRef is cellXMLReferenceData-> GetReference();.

  • How to add text to the file selected?

    I have already updated title but I don't know how to add it to the selected real file (the one in the middle)... I read on some other forums but its still confuse me.  Also, is there anyway to add the effect of movement, as drag in or dissolve almost?

    Screen Shot 2016-02-19 at 10.27.40 PM.png

    I mean this in the nicest way possible, but it's very wacky workspace you put in place there. Create titles is muuuuch easier in the standard workspace Edition. When you create / open a title in the editing workspace, he creates a floating large window with the title of all the members of panels. It is about the only time I am ok with windows in the first floating. You will create the title in the window title, and then close the window title entirely. The video for the title will then be in your project Panel (which you can not common to see in your current workspace configuration, but will be very apparent in the workspace standard edition in the lower left). So the best thing to do is to simply drag the title element of the project to sequence Panel (another Panel today, you don't see in your current workspace arrangement.

  • My footer will not dynamically move when you add content to the body.

    I built a model with my envelope header and footer protected as unchangeable. I applied the template to all pages except the index.html page. When I add content in the content body inside a div box there will be blood in the area of the film instead of pushing down. So my menu wrap and footer must move down that I dynamically add content. How can I solve this problem?

    I understand that if I use a regular div tag and not an APdiv tag, I added the content it will then push the footer down. Sorry I am new to Dreamweaver.

  • Apply the style of Pará to the xml element based on the type of master page?

    IM using a flow xml, im importing the xml to be used across different master page templates and I want to apply paragraph styles different items depending on what master page xml, they are on...

    So I have 3 put templates in place

    Type of page 1

    Type of page 2

    Type of page 3

    and 3 paragraph styles

    style 1

    style 2

    style 3

    I have the same xml structure deposited on each page...

    < Entry >

    < name > Page < / name >

    < / name >

    So, can I use javascript to apply the paragraph (style 1) style to the xml element (name) on any page that uses the master page (type of Page 1)

    Is this possible? whether and how this could be done?

    Thanks in advance

    Hello

    Try:

    #include '... / XML rules/glue code.jsx ";

    myDoc var = app.documents.item (0);

    var myRuleSet = new Array (new applyParaStyle());

    {with (MyDoc)}

    var elements = xmlElements;

    __processRuleSet (Elements.Item (0), myRuleSet);

    }

    function applyParaStyle() {}

    myIdName = "Xp".

    This.XPath = "//restaurant_name";

    This.Apply = function (myElement, myRuleProcessor) {}

    {with (MyElement)}

    {Switch(insertionPoints[0].parentTextFrames[0].) ParentPage.appliedMaster.Name)}

    case "X-Master:

    App.Select (texts);

    App.Selection [0]. FillColor = myDoc.colors.item ("xxxx");

    break;

    case 'guide-Scotland:

    App.Select (texts);

    App.Selection [0]. FillColor = myDoc.colors.item ("scotland");

    by default:

    break;

    }

    }

    Returns true;

    }

    }

  • How to add text to the Notes?

    Hi all

    I want to add some text in the notes. I create notes with success.

    My note label and name are not apply any script executed successfully.

    How to add text to the note? My script is:

    indesign #target

    myDocument var = app.documents.add ();

    var myTextFrame = myDocument.pages.item (0).textFrames.add ();

    myTextFrame.geometricBounds is ['10', 15 ' p', '50 p', '50 p'];.

    myTextFrame.contents = "Adobe Indesign";

    var insertionPoint = myTextFrame.insertionPoints.item (-1);

    var note = insertionPoint.notes.add (1433299822);

    Note.label = "NewNote";

    Note. Name = "FirstNote";

    Thank you

    Jin

    try sth. like

    Note.texts [0] .silence = 'some content '.

    Hans-Gerd Classen'

Maybe you are looking for

  • Satellite L300-147 - windows fails to load \Boot\BCD

    When I turn on my laptop windows will not load. I do not have installation discs and I can not load in safe mode or anything. The file is \Boot\BCD status is 0x000000f. The info is "an error occurred trying to read the boot configuration data. Can yo

  • Satellite A100 - 237 (PSAA9E) - unable to install the ATI driver

    I installed Windows 7 32 bit ulitmate. When I click to "tuninstall.exe", nothing happens (givent pilot error but do not work). Help me please? and few other pilots gives the same error. :(son exp.)

  • Try to burn a cd with XP Recovery on that Console.

    I've read various instructions on how to do it, but my 3 attempts so far have not resulted in a bootable cd. Some of the advisers to show how to do it using NERO. I have NERO 7 that came with a new Sony CD/DVD burner, but they show the screenshots is

  • When Comcast change outgoing email smtp port 25 to 587?

    All of a sudden, I could not send email with Comcast. Chat live Lady says to set the port to 587 smtp. It has alsways been port 25. She said that they have not changed anything. MS Outlook probably does not change all by itself. Frustrating. Has anyo

  • Windows 7 Explorer.exe Crash

    Hello I have a computer Windows 7 x 32 and my Windows Explorer.exe crashes. Explorer hangs even when I have a window unique explore open. I managed to get a .dmp file and it said: This dump file is an exception of interest stored in it. The stored ex