Home Forums General XMetaL Discussion Macro to search through attribute value Reply To: Macro to search through attribute value

Derek Read

Reply to: Macro to search through attribute value

There's almost always a way. Just need to define the problem in enough detail to understand what needs to be done.

Maybe something like this is what you need.

//XMetaL Script Language JScript:
//name of element you are looking for
var elemName = "ref-callout";
//create a range to walk through the document
var rng = ActiveDocument.Range;
//move the range to the start of the document
rng.MoveToDocumentStart();
//for every element that matches the right element name...
while(rng.MoveToElement(elemName)) {
//...if that element has an @href with the value r101
if(rng.ContainerAttribute("href") == "r101") {
Application.Alert("found one...");
//do whatever you need to do to this element here...
}
}

Reply

Products
Downloads
Support