You could use this:
var myDoc = app.activeDocument;
var myTF = myDoc.textFrames.everyItem().getElements();
for (var k = 0; k < myTF.length; k++)
1st boolean parameter means to clear the TextFrame's existing attributes before applying the style;
2nd boolean parameter means to clear attributes and formatting applied to the TextFrame that are not defined in the object style.
hope it could help you, ciao
Thank you so much this is just perfect, exactly what I needed!
Thank you for your script!
Now my second problem is that it does not work with enchored objects. I need to re-apply the style also to those object if not the next parragraph style does not apply after importing Xml.
Thank you for your time and help