How can I add a smart part to a page programmatically

Jun 8, 2013 at 9:57 AM
Hi,

How can I add a smart part to a page programmatically ? I can add a content editor web part as given below:
        ContentEditorWebPart oCWP = new ContentEditorWebPart();
        XmlDocument xmlDoc = new XmlDocument();
        XmlElement xmlElement = xmlDoc.CreateElement("Root");
        xmlElement.InnerText = "some text"; 
        oCWP.Content = xmlElement;
        oCWP.Content.InnerText = xmlElement.InnerText;
Please advise.