簡體   English   中英

如何將XML響應字符串轉換為字典或數組?

[英]How to convert XML response string into dictionary or array?

這是解析XML響應並將其追加到字符串后得到的。

附加的字符串是:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://xxx.yyyy.in/soap/hubbuch/"><SOAP-ENV:Body><ns1:isValidDVNResponse><response>a:10:{s:11:"sso_user_id";s:6:"656451";s:9:"firstname";s:0:"";s:8:"lastname";s:0:"";s:5:"abono";s:0:"";s:4:"hash";s:32:"554457e710839bc3039f6bc81839688e";s:5:"token";s:32:"238e70c6661489bfa6a8a84f2e1aa0f1";s:5:"login";s:23:"x@y.in";s:6:"cookie";s:232:"&lt;img style="width:0px; height:0px;" src="http://xxx.yyyy.in/sso/cookie.php?aktion=set&amp;hash=554457e710839bc3039f6bc81839688e&amp;token=238e70c6661489bfa6a8a84f2e1aa0f1&amp;time=10000&amp;login=x%40y.in&amp;alias=14,15,16" alt="" /&gt;";s:6:"access";a:1:{s:4:"role";s:2:"NO";}s:5:"error";s:0:"";}</response></ns1:isValidDVNResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

如何從該字符串中獲取適當的字典或數組? 因此,它具有鍵值對。

注意:-不需要a:10,s:11,...。

謝謝..

您可以使用XML to JSON字典解析,通過使用XMLDictionary解析器將所有XML數據解析為Dictionary。

github上的一個不錯的項目,它將所有xml數據解析為字典。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM