How to display players XP levels on Scoreboard

I've tried using command blocks only.
I googled but couldn't find anything.
Best Answer
I see two main ways to do this, neither of which are that great. If it's not necessary, I'd recommend not doing this.
First way would be to set the score individually for each level, like this:
/scoreboard players set @a[l=0,lm=0] XPScore 0
/scoreboard players set @a[l=1,lm=1] XPScore 1
/scoreboard players set @a[l=2,lm=2] XPScore 2
...
The main problem with this method is that you'll need a ton of command blocks. I'd probably go with supporting 127 levels if this is just vanilla/survival.
Next method is a bit more complicated, but would cut down the command blocks needed from 127 to around 30 whilst still supporting the same max level.
First, you'd set everyone's XP score to 0:
/scoreboard players set @a XPScore 0
Then, in this exact order, run these commands:
/scoreboard players add @a[lm=64] XPScore 64
/xp -64L @a[lm=64]
/scoreboard players add @a[lm=32] XPScore 32
/xp -32L @a[lm=32]
/scoreboard players add @a[lm=16] XPScore 16
/xp -16L @a[lm=16]
/scoreboard players add @a[lm=8] XPScore 8
/xp -8L @a[lm=8]
/scoreboard players add @a[lm=4] XPScore 4
/xp -4L @a[lm=4]
/scoreboard players add @a[lm=2] XPScore 2
/xp -2L @a[lm=2]
/scoreboard players add @a[lm=1] XPScore 1
/xp -1L @a[lm=1]
This should set everyone's XPScore to their XP. Problem is that it also sets their XP to 0, so afterwards you need to clone their XPScore to another objective, I'll call mine "XPTemp":
/execute @a ~ ~ ~ /scoreboard players operation @p XPTemp = @p XPScore
Then you need to set their XP level back to what it was before using pretty much the reverse of what was above.
/xp 64L @a[score_XPTemp_min=64]
/scoreboard players remove @a[score_XPTemp_min=64] XPTemp 64
/xp 32L @a[score_XPTemp_min=32]
/scoreboard players remove @a[score_XPTemp_min=32] XPTemp 32
/xp 16L @a[score_XPTemp_min=16]
/scoreboard players remove @a[score_XPTemp_min=16] XPTemp 16
...
Pictures about "How to display players XP levels on Scoreboard"



How do you show your level in Minecraft?
When you use the L attribute with the /xp command, you add experience levels to a player. An experience level is one entire bar filled. When you add an experience level, you will see the experience level counter for the player increase. Type the command in the chat window and press the Enter key to run the command.How do you set the XP level in a player?
Via the /scoreboard objectives setdisplay command (see command reference), players' scores in specific objectives can be displayed in certain 'slots' in-game. Each 'display slot' can show one objective at a time, and multiple 'display slots' may be used for the same or different objectives.Minecraft - Set XP to Scoreboard
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anthony, Kelly, Mike B, Yaroslav Shuraev