zoukankan      html  css  js  c++  java
  • 解析XML字符串为json对象

      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))
    

      

  • 相关阅读:
    Luogu P3275 糖果
    Python基础学习
    SharePoint 2013
    Office
    KnockoutJS
    SharePoint 2013
    Bootstrap
    SharePoint 2013
    CSS
    AngularJS
  • 原文地址:https://www.cnblogs.com/liuhao-web/p/7239807.html
Copyright © 2011-2022 走看看