To move the anchored text frame you have to move the character, that is representing the anchored object in your text flow.
If you select your anchored text frame, the parent of that will be the character to move.
Something like that should work:
var anchoredObject = app.selection; var characterToMove = anchoredObject.parent; var mainStory = characterToMove.parent; var indexOfFirstInsertionPoint = characterToMove.paragraphs.insertionPoints.index; characterToMove.move ( LocationOptions.BEFORE , mainStory.insertionPoints[indexOfFirstInsertionPoint-1] );
Did not test that with XML tagged contents.