Home › Forums › General XMetaL Discussion › Getting value of an attribute using getNodesByXPath › Reply To: Getting value of an attribute using getNodesByXPath
Reply to: Getting value of an attribute using getNodesByXPath
September 2, 2009 at 9:26 pmDavid, try this:
[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
var nd = rng.ContainerNode;
var id = nd.getNodesByXPath('ancestor-or-self::*[@id][1]/@id');
if(id.length > 0) {
Application.Alert(“Node Name: ” + id.item(0).nodeName);
Application.Alert(“Node Value: ” + id.item(0).nodeValue);
}[/code]