Home Forums General XMetaL Discussion node list issues/questions Reply To: node list issues/questions

Derek Read

Reply to: node list issues/questions

One thing I don't think our docs state clearly (if at all) is that your “nodelist” variable is dynamic, meaning that changing the DOM node tree affects your variable (it might seem odd but that's the way it works).

Here is a simplified example that does what your script is trying to do, which his to give all filter attributes that currently have a value of “filter5” a value of “” (empty string).

[code]var nodelist = ActiveDocument.getNodesByXpath(“//*[@filter='filter5']”);
var nodecount = nodelist.length;
Application.Alert(“Fixing ” + nodecount + ” nodes…”);
for (i=0; i nodelist.item(0).setAttribute(“filter”, “”);
}[/code]

Note: I assume you specifically wish to set the value to an empty string, rather than removing the attribute (which is technically different and will be treated differently by some XML processors). If you want to remove the attribute instead you can use this: nodelist.item(0).removeAttribute("filter")

Reply

Products
Downloads
Support