A simple example: Let's say you are level 2 with a total xp bank of 2500. Your character sheet will display that you have 1000 xp, as that is the amount required to reach level 2. The remaining 1500 is your progress toward level 3, and is hidden from you. You can get a feel for the progress between levels by reading the messages that are displayed when you rest, but the actual number is not shown.
Now assume you are somehow able to enchant an item at level 2 that costs 2000 xp. 2500 - 2000 = 500. Since this is enough of a loss to drop you below the 1000 xp requirement for level 2, you will see a message saying you have lost 1000 xp, and your sheet will display Level 1 with 0 xp, even though you still have 500 xp banked toward level 2.
If the cost to enchant was 1500 or less, you would remain level 2 and you wouldn't see an xp loss message.