Share via


OneNote 2010 XML Schema

Following up on yesterday's release of the C++ header, we're publishing the OneNote 2010 XSD schema, which should make it easy for you to validate your XML data when reading or writing to the COM API. You can also use it to auto generate classes for native OneNote data structures using Visual Studio , and I've written up a short tutorial on how to do that.

Generating Classes from XSD Files

1.) Start an elevated command prompt, and create a new folder called OneNoteClasses in your C drive

  cd C:\
 
 mkdir OneNoteClasses 

2.) Visual Studio 2010 packs a powerful XSD manipulation tool - xsd.exe, which we will use to generate our classes. Navigate to the bin folder that contains xsd.exe (or add the folder your PATH variable) : 

  cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\

3.) We're going to run the XSD.exe tool with a few parameters - the source XSD file,  a flag that tells it to generate classes for the data types, and an output folder. In this case, I have my xsd file on the C: drive, so I run: 

  xsd.exe C:\OneNote14Schema.xsd /c /out:"C:\OneNoteClasses"

This should create a C# (.cs) file in your folder which contains all the classes, which is around 5600 lines of code. You can find more documentation about using xsd.exe here.

Alternatively, you could use Xsd2Code, a plugin for Visual Studio that lets you run the same command from the GUI.

OneNote14Schema.xsd

Comments

  • Anonymous
    August 28, 2011
    thanks for the writup, succinct as ever, www.liquid-technologies.com/xml-editor.aspx

  • Anonymous
    January 19, 2012
    Good tip, http://www.xmlblueprint.com/.

  • Anonymous
    June 23, 2014
    Great directions!  I was able to build this into a DLL and link into my project very quickly.  However, I am a bit stuck as to how to use the classes.  Mainly, I don't understand how they are populated with any data from OneNote.  Is there any other resource you could link that has information on how to use the classes?