Using XMetaL 4.6 (but upgrading soon). I'm writing a script that will iterate through elements that have titles but no id attributes and present the user with a dialog showing the title and a suggested id based on that title (with spaces and weird characters removed). The user can change the id or skip this one. It's all easy enough except getting the text of the title elements. The <title> might have inline markup, but what I want are all the text() children of the title:
I've tried the following, but titleText.lenght is always 0.
needIds = ActiveDocument.getNodesByXPath("//*[not(@id) and ./title]");
titles = ActiveDocument.getNodesByXPath("//*[not(@id) and ./title]/title");
for (var i=0; i < needIds.length; i++){
needsId = needIds.item(i);
title = titles.item(i);
titleText = title.getNodesByXPath(".//text()");
Application.Alert("titleText=" + titleText.length);
}
Basically, I want to get what I would get using <xsl:value-of select="normalize-space(title)"/> for a given title element.
Thanks,
David