I am having the same problem, actually now for like fifth time already. I own my xps 9560, i7 for like 2-3 years. Dell is absolutely silent about this, so your only chance are forums like this (or Pro-Support, see below). I checked a lot of times and I am 100% sure it was never caused by wrong adapter, bent pin, worn jack, loose socket, bad battery or some software nor bios issue etc. People that are giving advice to check these things must be assuming you are a complete retard or maybe they fixed few computers like this and then they think they know everything. Let me tell you that about this particular issue, they know nothing. Nobody has so far solved this one and it is a very frustrating one. It seems to be not so rare either.
First time I let the Dell service solve it (pro support). After some initial remote troubleshooting to exclude the case you are an idiot who cannot use google, a technician came with a motherboard and replaced it. It worked for half a day until it happened again. Strangely enough, when I was messing with the computer myself (like unplugging/plugging battery at random times), I (very rarely) managed to charge it to full. However, it never stayed for long. So they took it, send it somewhere (Poland?), where another technician exchanged the power socket with AC cable + motherboard. Since then, it worked fine for a long time, although very occasionally, the battery stopped to charge, but only temporarily. What I observed is that the issue is much more likely to trigger when you don’t plug the adapter into the wall socket directly, but use whatever kind of an extension cord or fork. So it is likely to be caused by some fluctuations in the input power. Although one would think that the adapter takes care of that, it seems it doesn’t. To support this, I also observed there is relatively high probability of the issue to trigger when you plug the computer into a socket on a train and then they switch the power off and on again (at stations etc.). So it seems something gets (progressively?) damaged inside computer, but it is unclear what. Sometimes I managed to resolve the issue by disconnecting the adapter in the middle, reconnecting the wire to the computer’s socket and connecting the middle again (or some permutations of that). This time however, it does not work anymore and I am now running the machine without battery (it won’t start with depleted battery, but starts without it - makes sense). I already tried to replace the socket and AC cable myself, but it did not help.
In conclusion, it seems that the only reliable fix is to replace the AC cable + motherboard at the same time (and then stay away from extension cords and train sockets), but since I tried this solution only once, I can’t even guarantee that. The motherboard is not a cheap part and obviously lot of screwing to change, so you will probably be better with extending your warranty and letting them repair it.