It has been awhile since I have posted anything about the OneNote API and I apologize/apologise for that; we are busy planning the next release of OneNote. In fact if I haven't mentioned it before the codename is Office14, the code names are always based on the version number of Office. So while we have a bunch of great ideas of for the next release of OneNote we are always listening for suggestions and comments. If you have thoughts please email me or use our Connect site.
That being said I wanted to answer a question that came my way a few days ago from Michael @ Mindjet (see his addin here). He wanted to know this:
How do I determine the section that is currently visible to the user.
Well here is a quick method to help you with that:
strNamespace = "http://schemas.microsoft.com/office/onenote/2007/onenote";
the xml into a document
xmlDoc = new XmlDocument();
the hierarchy from the root to pages
an XmlNamespaceManager for resolving namespaces.
nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
the page ID of the active page
xmlActivePage = (XmlElement)xmlDoc.SelectSingleNode("//one:Page[@isCurrentlyViewed=\"true\"]",
strActivePageID = xmlActivePage.GetAttribute("ID");
So I bet if you wanted to do the same thing for the sections you could just change the SelectSingleNode XPath query from one:Page to one:Section and it will work. Actually this is correct! And you can change your query to only be for hsSections as well.
xmlActivePage = (XmlElement)xmlDoc.SelectSingleNode("//one:Section[@isCurrentlyViewed=\"true\"]",
And finally for the currently viewed notebook:
xmlActivePage = (XmlElement)xmlDoc.SelectSingleNode("//one:Notebook[@isCurrentlyViewed=\"true\"]",
So this is just something that Michael asked me and I wanted to share with all of you.
All the code examples I see for AddNamespace() in relation to OneNote hardcode a namespace, which to me seems like a bad idea. It locks you into the current version you're working against. Why not do this instead?
That way you look up with the same namespace as what is already in the document, making it version free.
Hi all! -
[url=http://lineage2account.mybbland.com]lineage 2 accounts[/url]
<a href="http://lineage2account.mybbland.com">lineage 2 accounts</a>
How to use FindPages method for onenote to search pages within section.