China witnessed a net inflow of foreign investment last year even amid challenges posed by overseas central banks' interest rate hikes, official data showed.