If you have an application which creates notes, learning how to integrate evernote to sync notes will be very handy.

You may refer this ruby gem - [evernote_oauth][1] which has useful methods to access your existing evernote notebooks, create notebooks and notes, etc. The gem is well documented.

Refer this blog to understand and see code to create note on evernote - [Create Note on Evernote][2]

If you refer the code in the above blog to create a note - just this particular snippet -

n_body = ""

n_body += ""

n_body += "#{note_body}"

Create note object

our_note = Evernote::EDAM::Type::Note.new

our_note.title = note_title

our_note.content = n_body

So, the n_body is an xml content.

And note_body in our case was simple text of the note user entered. This was not xml, which can be a problem if it has some characters like <, >, ", ', &.

Upon encountering these symbols the createNote was failing with an error like this

<Evernote::EDAM::Error::EDAMUserException errorCode:ENML_VALIDATION (11), parameter:"The entity name must immediately follow the '&' in the entity reference.">

Reading this article - [article-link][3] helped me to understand the issue. Basically it says the characters <, >, ", ', & are special and has special treatment by the XML parser.

Special characters should be escaped. For example, & should be & amp; and similar for other four characters. Ruby Code to do that is:

n_body += "#{note_body.encode(:xml => :text)}"

This will convert the note text to a valid xml

Hoping it helps!
[1]: https://github.com/evernote/evernote-oauth-ruby
[2]: https://dev.evernote.com/doc/articles/creating_notes.php
[3]: http://stackoverflow.com/questions/16303779/the-entity-name-must-immediately-follow-the-in-the-entity-reference