XML : XML to JSON converter xml_str2json returns null?

When I use following code:

  $http.get("http://6b8dc686.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder").success(function (data) {                  var x2js = new X2JS();                  var jsonData = x2js.xml_str2json(data);                  console.log("debug", data);                  console.log("debug", jsonData);              });    

jsonData is null, it seems related to my xml output from the link: http://6b8dc686.tunnel.mobi/yii2-basic/web/index.php?r=duangorder/restorder

  <response>  <item>  <id>1</id>  <token>gh_9831478f66cb</token>  <order_id>143978240336383</order_id>  <openid>oPuB9wkVKTXn9AZ9idM-XqhUvxh0</openid>  <table_id>0</table_id>  <ctime>1439782403</ctime>  <phone>13211675827</phone>  <address>云南昆明 详细地址</address>  <remark/>  <detail>  {"4":{"num":2,"id":"4","name":"\u86cb\u7092\u996d","price":"10.00","total":20},"6":{"num":1,"id":"6","name":"\u626c\u5dde\u7092\u996d","price":"10.00","total":"10.00"},"5":{"num":1,"id":"5","name":"\u51b0\u6dc7\u51cc","price":"8.00","total":"8.00"}}  </detail>  <name>霆鈞</name>  <processed>0</processed>  <paid>0</paid>  </item>  <item>  <id>2</id>  <token>gh_9831478f66cb</token>  <order_id>143979224136359</order_id>  <openid>oPuB9wkVKTXn9AZ9idM-XqhUvxh0</openid>  <table_id>0</table_id>  <ctime>1439792241</ctime>  <phone>13211675827</phone>  <address>云南昆明 详细地址</address>  <remark/>  <detail>  {"4":{"num":1,"id":"4","name":"\u86cb\u7092\u996d","price":"10.00","total":"10.00"}}  </detail>  <name>霆鈞</name>  <processed>0</processed>  <paid>0</paid>  </item>  <item>  <id>3</id>  <token>gh_9831478f66cb</token>  <order_id>143995577636336</order_id>  <openid>oPuB9wkVKTXn9AZ9idM-XqhUvxh0</openid>  <table_id>0</table_id>  <ctime>1439955776</ctime>  <phone>13211675827</phone>  <address>云南昆明 锦苑花园32幢202室</address>  <remark>快点哦</remark>  <detail>  {"5":{"num":2,"id":"5","name":"\u51b0\u6dc7\u51cc","price":"8.00","total":16}}  </detail>  <name>霆鈞</name>  <processed>0</processed>  <paid>0</paid>  </item>  </response>    

but i've tried following link and my xml is valid: http://www.xmlvalidation.com/index.php?id=1&L=0

I want to know where the problem is? thanks.

No comments:

Post a Comment