look the same, if they are equal move them to a function and use it in both places.
function setOrAddAttr(xmlAttrs, value) {
if (!xmlAttrs.item(key).isValid) {
xmlAttrs.add(key, value);
}else{
xmlAttrs.item(key).value = value;
}
}
function setOrAddSyncScript(xmlAttrs, syncScript) {
setOrAddAttr(xmlAttrs, "syncScript", syncScript);
}
function setOrAddSyncIdentifier(xmlAttrs, syncIdentifier) {
setOrAddAttr(xmlAttrs, "syncIdentifier", syncIdentifier);
}
setOrAddSyncScript(tagObject.associatedXMLElement.xmlAttributes, syncScript);
setOrAddSyncScript(tagObject.parentStory.associatedXMLElement.xmlAttributes, syncScript);
setOrAddSyncIdentifier(tagObject.associatedXMLElement.xmlAttributes, syncIdentifier);
setOrAddSyncIdentifier(tagObject.parentStory.associatedXMLElement.xmlAttributes, syncIdentifier);