🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2371

Re: Changing Values in XML tags

#2371
From: Peter Kahrel
Date: Thu, 01 Jan 2009 21:18
22 lines
1415 bytes
Come to think of it, XML structures can be traversed just like folders with files and subfolders, topic lists with topic names and subtopics, etc. Here is a function that goes through an XML tree and changes the contents of an XML element with a certain tag:



change_tag (app.activeDocument, 'ART_PRICE', '0.0');

function change_tag (doc, myTag, new_value) 
   { 
   for (var i = 0; i < doc.xmlElements.length; i++) 
      { 
      if (doc.xmlElements[i].markupTag.name == myTag) 
         doc.xmlElements[i].contents = new_value; 
      else 
         change_tag (doc.xmlElements[i], myTag, new_value); 
      } 
   }



I seem to remember reading somewhere that this is a slow method compared with XPath (which you can use from CS3) but again, I don't know how that works.

Peter
Technical Details
Message-ID: <59b7651b.7@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
References: <59b7651b.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,d78f6b73256f6f00
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter Kahrel" <kahrel@kahrel.plus.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: Changing Values in XML tags
Message-ID: <59b7651b.7@webcrossing.la2eafNXanI>
Date: Thu, 1 Jan 2009 13:18:02 -0800
References: <59b7651b.-1@webcrossing.la2eafNXanI>
Lines: 26
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit