Home Forums General XMetaL Discussion Scripting: Something like getElementsByTagName, for specific attribute & value? Reply To: Scripting: Something like getElementsByTagName, for specific attribute & value?

Derek Read

Reply to: Scripting: Something like getElementsByTagName, for specific attribute & value?

The API getNodesByXPath will allow you to return a list of element nodes that have specific attributes set. Here is an example that tells you how many

elements in your document have an id attribute value:
[code]
// XMetaL Script Language JSCRIPT:
var parasWithId = ActiveDocument.getNodesByXPath(“//p[@id]”);
Application.Alert(parasWithId.length);[/code]

This API returns a DOMNodeList of DOMElement objects. For more information refer to the XMetaL Developer Programmers Guide.

Reply

Products
Downloads
Support