Change the content with XPath

Hi all

I'm trying to find XML items in my document by using XPath and then modify its content. I realize that this is supposed to be a pretty simple action, but the documentation on this subject is surprisingly rare/little claire (or maybe my search skills simply lack).

Currently, I tried to use evaluteXPathExpression, but I have no idea if that's the right way to go. By any means, any iteration that I try to get through.

var myDocument = app.activeDocument;
var myRootXML = myDocument.xmlElements[0];
var myXMLPath = myRootXML.evaluateXPathExpression("//Test[1]/Test[1]");
myXML.insertTextAsContent("Sample text", XMLElementPosition.ELEMENT_END);

Regards and thanks in advance.

Julian

For this simple task you need not the processor complicated rule. And edit with grep is also only for lovers of strong sensations.

Your problems:

-evaluateXPathExpression returns an array

-assign you the result to a variable, but use a different

var myDocument = app.activeDocument;
var myRootXML = myDocument.xmlElements[0];
var myXMLPath = myRootXML.evaluateXPathExpression("//Test[1]/Test[1]");
if( myXMLPath.length>0 ) {
  var myXML = myXMLPath[0];
  myXML.contents = "Bla";
 myXML.insertionPoints.lastItem().contents = "++";
  myXML.insertTextAsContent("Sample text", XMLElementPosition.ELEMENT_END);
}

I've never used insertTextAsContent, it might work, but I have provided alternatives in any case.

HTH,

Dirk

Tags: InDesign

Similar Questions

  • change the contents of a file with the file in 11g adapter

    Hello

    This question is perhaps not very smart, but I'm new here so please bear with me for a second

    My question can I change the contents of the file with the FTP adapter, but 11.1.1.5.

    If Yes, what is involved in the making, any link to a sample or any guidance is appreciated.

    Thank you

    Anatoliy salvation,

    There are many samples available on the net...

    https://Java.NET/projects/oraclesoasuite11g/pages/FileAdapters

    http://erpschools.com/articles/BPEL-file-adapter-tutorial

    See you soon,.

    Vlad

  • I'm changing the content of a tab. Can't find information anywhere! My new tab to come as a Google search page. Now it's Bing, and I don't want Bing

    I'm changing the content of a tab. Can't find information anywhere! My new tab to come as a Google search page. Now, it's Bing, and I don't want Bing. I uninstalled the program who inadvertently put there but rest of Bing. Where is the control tab hooks me up with tab content?

    Deletion of comment by dupe

  • Why can't I change the content at different breakpoints?

    For some reason, after the establishment of breakpoints on my master, whenever I try to change the content at different points of rupture on my subsequent pages, if I click on a breakpoint I can get to this provision of breakpoint, but the cursor turns into a pen and a circle with a line through it and says 'Click here to directly access the breakpoint'.  If I click once again, I need to come back on the breakpoint (1200px) original on as I was.  Can someone tell me why I can't edit content on other breakpoints?

    You cannot change the content between breakpoints.

    If you want a breakpoint of master page to be accessible on a layout page (which is not make sense in many cases), click the small arrows, who are appearing in the breakpoint bar, which represents your breakpoints in the master page, and then click the 'create a new breakpoint' that appear :

  • change the content of the e-mail

    Hi all,

    I send the notification by e-mail with the content of the (name of VM dashboard)

    look like the email I receive:

    "your VM is:

    VM1, vm2, vm3 vm4... »

    I want that the e-mail will be look like:

    "your VM is:

    VM1

    VM2

    VM3... »

    any idea?

    Yes, change the contents of an array of strings into a string object... break to the top of the table and be in HTML format:

    var content = "Your VM's are: ";
    for each (vm in vms){ // assuming the array of vms variable is named "vms"
    content += vm.name + "
    "; }
  • How to change the content of the 'account name' column in the' overview of accounts. "

    Hello

    I use Oracle Identity Manager 11 GR 2!

    In the Self-Service under "My access", I see a list of all the service accounts. If for example I create a account, then there's a strage number displayed in the "Account name" column  See my photo...

    See the image: IOM user

    My question is, how can I change the contents of this column? I never put this number!

    Thank you!

    BR

    To change the name of the account to the account user id, you can follow the instructions below:

    1. open the form of the process of the resource that you want to display the user id as the name of account, instead of this strange number for example. UD_IPNT_USR

    2. create a new version of the form.

    3. go in the Properties tab.

    4. Select the user ID property and click on add property button.

    5. Select the account name and the value is false.

    6. save the form and make the version active.

    7 connect to IOM self-service console, select a user with iplanet account for her. You can see the user id of the account in the account instead of the strange number name,

    HTH

  • separate the elements of a path without changing the content

    Hello everyone!

    I need assistance with a very simple problem...

    I did a clipping of a compound path mask and now I need to separate items in the path composed without changing the content, but I'm not be able to extend...

    Here is a screenshot of the form, I need to move and use each rectangle separately!

    Thank you gor your help!

    Jimena

    Captura de pantalla 2014-07-06 a la(s) 23.02.42.png

    Jimena,

    There's the destructive Act dirty with the selected clipping mask:

    (1) in the drop-down list the palette/Panel transparency list select everything except Normal (Multiply is fine; this step may not be necessary in your version, you can try;

    (2) object > flatten transparency, just keep the defaults including 100% vector.

    (3) thrill.

    Or you can use (16) the separate clipping mask, each being used on a copy separate from the underlying work.

  • Possible to change the contents of text inside the group frame?

    Hello world

    I'm newbibe to Indesign forums.

    I had grouped image placed on the rectangle frame and the text. now I need change content text frame using indesign Javascript

    Possible to change the content of text inside the group frame... ?

    -yajiv

    Hello

    Try the following lines.

    main();
    
    function main() {
    
        if  (app.documents.length != 0  &&  app.selection.length == 2 ) {
            if( app.selection[0].constructor.name == "Group" && app.selection[1].constructor.name == "Group" ) {
                var sel1 = app.selection[0];
                var graphics1 = sel1.allGraphics[0].itemLink;
                var text1 = sel1.textFrames[0].contents;
    
                var sel2 = app.selection[1];
                var graphics2 = sel2.allGraphics[0].itemLink;
                var text2 = sel2.textFrames[0].contents;
    
                sel1.textFrames[0].contents = text2;
                sel2.textFrames[0].contents = text1;
    
                var fP1 = File( graphics1.filePath );
                var fP2 = File( graphics2.filePath );
    
                graphics1.relink( fP2 );
                graphics2.relink( fP1 );
            } // if
            else {
                alert ( "Select 2 groups!" );
            } // else
        } // if
        else {
            alert ( "Wrong selection!" );
        } // else
    } // main
    

    Although it might work for you, it is probably not advisable, because if you apply other content on the chassis, you modify the content, but not the formatting. Even with the restoration of the links of the images.

    So a better solution may be, separate frames, move them and group them back.

  • Changing the content ID method

    Hi all

    What about the content ID of the content whether active documents/web or etc.

    During export/import content, is there a way to change the content ID to something else batch and no severance of the relationship with the Site that use web/content or other assets?
    for example. Initial content for content ID is ABC_XXXX01 XYZ_XXXX01where ABC and XYZ view the prefix and the XXXX01 is to refer to the sequence number

    Or what is the common/practice method to change the content for an entire site id?

    Thank you

    Or what is the common/practice method to change the content for an entire site id?

    In general, archive them is option one here - you should be able to define export/import content items and to define the logic of transformation as part of it.

    I don't know everything, if it maintains the link also to WCM objects. For example,.
    -you have a static list, referring to a piece of content, which now has a new ID, or
    -you have a region assigned to a content element, now with a new code.

    It should be relatively easy to identify.

    UCM 11 g since, I think, PS3, also contains an export/import feature a Web site. So, you could also try this one.

  • Others may change the content of the site?

    Hey, it's the newbie again. Probably an easy question...

    I wonder... I was Admin on a site that someone else built. They have an online administration page, where admins can change the content of the pages (but not the model) by logging in to the part of the administrator of the site.

    I took that Dreamweaver does what we call "contribute", but from what I can tell, you have to buy software. I am quickly (with no prior knowledge of Web site design) design a site for a group that has a free online e-magazine (aka, they have no money to buy the software, and they don't have a copy of DW).

    Now, the editor-in-Chief of the magazine wants a way to modify the content itself - you know, adding a new sentances of couple, or update an image. It's pretty important because I can only update DW site on my dad's computer. And I can't get on his computer at the time that she sent me.

    Is it possible to do with DW?

    You need a content management system.

    CMSs come from large and small, depending on your skills with the code and the needs of your customers.

    Cushy CMS can be just what you need for this project (see their video to see how it works).  http://www.CushyCMS.com

    Seed content-

    Available in ASP, ASP.net or PHP

    No database needed.

    http://contentseed.com/

    WordPress, Joomla, Drupal and 5 concrete products open source (free) but you need coding skills in PHP, MySQL, HTML and CSS to implement and customize themes.

    Free CMS 10 + most mentioned here:

    http://woork.blogspot.com/2008/11/10-free-powerful-content-management.html

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    http://ALT-Web.com/
    http://Twitter.com/ALTWEB

  • I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    Yes, you can have a one word title, by assigning a paragraph style title to this one word. No, you cannot change the text in a Table of contents, but you can change paragraph style font attributes (line) and add for example, a head of points between the types of OCD paragraph and page numbers. No part of the table of contents will not provide hyperlinks in exported PDF documents.

    When you look up in the menu bar, you can see the word iPages, or simply Pages. There is no product of iPages.

  • My screen iphone6 is cracked and in my country, they can only change the iphone with a new one and with a very high price. Is there anyway that I could replace just the screen?

    My screen iphone6 is cracked and in my country, they can only change the iphone with a new one and with a very high price. Is there anyway that I could replace just the screen?

    No, if you want to keep all rights to the service or support from Apple. Not to mention the fact that it then will be bork Touch ID and make the phone unusable if ever, you restore or update of iOS.

    Apple doesn't sell parts of the iPhone. There is no legitimate sources for replacement screens.

  • Im trying to change the content of my internet but it askes me the supervisor password and I never set one what do I do?

    Im trying to change the content of my internet but it askes me the supervisor password and I never set one what do I do?

    * original title - I do not know my supervisor password by trying to change the content of my internet, how can I know? *

    Hello

    1. what operating system is installed on your computer?

    2. what version of Internet explore is installed on your computer?

    3. you are the administrator of the computer?

    4. what internet content are you trying to change?

    5. where are you trying to change the content?

    Refer to this article on the lost or forgotten password: http://support.microsoft.com/kb/189126 of Microsoft's strategy concerning lost or forgotten passwords

  • HP Deskjet 710C does not print colors (also after changing the cartridge with a new one)

    HP Deskjet 710C on Windows XP

    Problem: Printer does not print color. Black printing works. It also does not print color now, I changed the color with a new cartridge. Remove the printer from Windows XP and reinstall also does not resolve it. Also by using the option in Windows/printer driver for the cleaning cartridge has failed. Anyone know a solution to this?

    There is a document about the lack of color of the issues on the printer Deskjet 710C that can be found here.

    I hope this helps!

  • Change the contents of the message body and keep the attachments using a FolderListener

    Hello

    I need to change the content of specific e-mails when they are received on the device. I use a FolderListener to detect when the message arrives, and I'm able to edit the content of the message. The problem is, attachments are lost in the process, but I need to keep. I just want to change the body of the message.

    Here is my code:

    public void messagesAdded(FolderEvent e) {
    
      Message m = e.getMessage();
      Object content = m.getContent();
    
      if (content instanceof Multipart) {
    
        Multipart mp = (Multipart) content;
    
        for (int idx = 0; idx < mp.getCount(); idx++) {
    
          Object part = mp.getBodyPart(idx);                
    
          if (part instanceof TextBodyPart) {
    
            mp.removeBodyPart(idx);
            break;
          }
        }
        TextBodyPart tbp = new TextBodyPart(mp, _res.getString(MSG_MAIL_CONTENT));
        mp.addBodyPart(tbp);
        m.setContent(mp);
      }
    }
    

    Any idea?

    Kind regards

    Stone

    Have you tried the cloning message? Then you can just copy the attachment to you original if it is lost.

Maybe you are looking for