/// <summary> /// Removes all of the outline elements in a OneNote page. /// </summary> /// <param name="path"></param> public void ClearContent(string path) { WriteVerbose("In ClearContent for " + path); XmlNode node = getOneNoteNode(path); if (node == null) { WriteInvalidPathError(path); return; } if (node.LocalName != "Page") { WriteError(new ErrorRecord(new ArgumentException("You may only clear the content of OneNote pages."), "InvalidArgument", ErrorCategory.InvalidArgument, path)); return; } WriteVerbose(path + " is a valid OneNote page."); string pageXml; ApplicationClass app = getOneNoteApplication( ); string pageId = node.Attributes["ID"].Value; WriteVerbose("Page ID is " + pageId); app.GetPageContent(pageId, out pageXml, PageInfo.piBasic); XmlDocument doc = new XmlDocument( ); doc.LoadXml(pageXml); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("one", OneNoteXml.OneNoteSchema); XmlNodeList outlineElements = doc.SelectNodes("//one:Outline", nsmgr); foreach (XmlNode outline in outlineElements) { string outlineId = outline.Attributes["objectID"].Value; WriteVerbose("Deleting outline: " + outlineId); app.DeletePageContent(pageId, outlineId, DateTime.MinValue); } }