Home › Forums › General XMetaL Discussion › node list issues/questions › Reply To: node list issues/questions
Reply to: node list issues/questions
March 18, 2015 at 5:22 pmI'm also pretty confused about DomNodeList.
I'm trying to iterate through a node list and change the type of each element found. With my current approach, the script misses every other element, so only half of the elements in a doc get changed.
My current approach was to get inside the element's contents, then change its container name. (sorry for the horrible following formatting:)
[code]//create a Range object to manipulate
rngText = ActiveDocument.Range;
foundTagsList = ActiveDocument.getElementsByTagName(“draft-comment”);
for (var j=0; j < foundTagsList.length; j++){
element = foundTagsList.item(j);
//convert the node into a selection (using Range)
rngText.SelectNodeContents(element);
//get the node's contents w/o containing tags
rngText.SelectContainerContents();
if (rngText.CanChange(“note”)) {
rngText.ContainerName = “note”;
}
}[/code]
background: my goal is to turn each