Don't repeat code in function parseFromXml

Don't repeat code in function parseFromXml

Have fun.

PS: It's my first pull request, so if I do sth wrong write here :)