In my experience, unfortunately, writing melodies is one of the most "magical" parts of writing music. Some melodies just sound great, some just don't. There are, however, a few things to keep in mind that can help you deliberately write a melody for a particular emotion or style and help you understand why a particular melody sounds good.

Intervallic and Stepwise Motion:
Some melodies have large jumps in-between consecutive notes, and others move up or down consecutive notes in a scale. The former usually sounds more grand, especially with slow rhythms, and the latter, smoother.

Rising and Falling Motion:
Whether the notes in a melody generally get higher, get lower, or stay in the same range can have a big effect on the melody's emotion.

Rhythm:
The melody you pick for a rhythm makes a huge difference. Is it syncopated or straight? Fast or slow? Complex or simple? Does it use distinctive tricks like hemiola or tuplets? What beats does it start and end on?

Instrumentation:
In my experience, the instrument playing a melody makes a big difference. In one electronic song I've heard, the main melody is played by a number of bold, powerful synths, giving the melody a driving emotion. Then, at the end of the song, a lone acoustic guitar plays the same melody, which suddenly becomes very sad.

Major/Minor Quality:
Of course, whether a melody is written in a major or minor key makes a big difference.

And the list can go on forever: tonal center, articulation, etc. The important thing isn't that every melody can be broken apart like this. Instead, you can pick out a few qualities you know you would like a melody to have based on which emotion you want to portray.

For example, perhaps you need to write the leitmotif for the bad guy. It's probably going to be in a minor key, because he's so evil. Likewise, it might be played in a lower register on an instrument like a bassoon, not on a lighter instrument like a flute. And although the motif will be centered around a particular key, it might use a lot of chromatic, dissonant notes. You can play with all the other attributes of a melody while you try to figure out what you're ultimately going to go with, but starting with a plan like this might make it easier to begin writing a melody.

Techniques for creating melodies
I'm facing some problems with Jsoup. I'm trying to retrieve an xml file from Open Movie Database using their API in my beta Android app.
Their API documentation says if the return type will be an xml just put an "r=" and the return file type.
I've tested with some requests. Below one of them:

Jsoup.connect(http://www.omdbapi.com/?i=tt1285016&amp;r=xml).get();


Testing on a browser works fine. But on android no. Any exception is thrown. If I don't insert the return file type, it returns a JSON. In this case I receive the data.
To make sure if the problem is with xml file. I've teste with MusicBrainz API. By default it returns XML. For my surprise works fine.

What is the problem? The return type of open movie database of Jsoup?
