Article View: adobe.scripting.indesign
Article #2373Re: Changing Values in XML tags
From: Dirk.Becker
Date: Thu, 01 Jan 2009 22:20
Date: Thu, 01 Jan 2009 22:20
34 lines
1609 bytes
1609 bytes
The use of XML Rules along the Adobe documentation is in my opinion overcomplicated, search the sample scripts for "glue code.jsx" if you're interested in details. Apparently Stefan R omitted that glue.
The script below demonstrates how I use the XML Rules.
Here the double slash works as wildcard in depth.
For details on xpath, see <http://www.w3.org/TR/xpath>
#target "InDesign"
function main()
{
var root = app.activeDocument.xmlElements[0];
var xpath = "//Product//ART_PRICE";
var node = null;
try {
var proc = app.xmlRuleProcessors.add([xpath]);
var match = proc.startProcessingRuleSet(root);
while( match!=undefined ) {
node = match.element;
node.contents = "0.0";
match = proc.findNextMatch();
}
if( node )
app.select(node);
} catch( ex ) {
alert(ex);
} finally {
proc.endProcessingRuleSet();
proc.remove();
}
}
main();
Technical Details
Message-ID:
<59b7651b.9@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<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: Dirk.Becker@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Changing Values in XML tags Message-ID: <59b7651b.9@webcrossing.la2eafNXanI> Date: Thu, 1 Jan 2009 14:20:53 -0800 References: <59b7651b.-1@webcrossing.la2eafNXanI> Lines: 36 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit