var overtime='<?xml version="1.0" encoding="UTF-8"?><response><code><liuhao>5555555</liuhao><age>555555555</age></code> <message>success</message> <totalCount>5000000</totalCount> <remainCount>4999883</remainCount> <DonateCount>12</DonateCount> <Limit>80088800</Limit></response>'; function parseXMLsimple(target){ var reg=/<([a-z,A-Z]+)>(.+)</1>/g; var obj={}; target.replace(reg,function(a,b,c){ obj[b]=reg.test(c)?parseXMLsimple(c):c; }) return obj; } console.log(parseXMLsimple(overtime))