Home › Forums › General XMetaL Discussion › Finding and returning exact insert location › Reply To: Finding and returning exact insert location
Reply to: Finding and returning exact insert location
September 23, 2015 at 7:32 amHello,
I use “XMetal Author Entreprise 9.0” and I have a problem with inserting at correct location.
My XML file has a number of “
My XML shema specify that “
When using my macro, the “
“…
AddElement(“//documentInfo”, “language”, elementValue);
…”
function AddElement(elementsName, elementName, elementValue)
{
var objNode = ActiveDocument.documentElement;
var objNodesList = objNode.getNodesByXPath(elementsName);
for (var index = 0; index < objNodesList.length; index++)
{
objRange = ActiveDocument.Range;
objRange.SelectNodeContents(objNodesList.item(index));
objRange.SelectElement();
objRange.Collapse(1);
if (objRange.FindInsertLocation(elementName, true))
{
objRange.InsertWithTemplate(elementName);
objRange.TypeText (elementValue);
}
else
{
ActiveDocument.Host.Alert(“Insert location not found.”);
}
}
}
***
Other problem :
When “objRange” is “
Final ouput should be