2014-02-21 39 views
1

我有一個控制器,它在這一格式獲取數據回從外部支付門戶:C#解碼request.inputstream

狀態=%3CportalRes +的xmlns%3D%22http%3A%2F%2Fwww.e- paycapita.com%2Fportal%22%3E%3CrequestID%3E7%3C%2FrequestID%3E%3CreqStatus%3E%3CstatusCode%3E0%3C%2FstatusCode%3E%3Cmessage%3EPayment + - +塞爾+ - +處理+完成+成功%3C。 %2Fmessage%3E%3C%2FreqStatus%3E%3CauthDetail%3E%3CresponseCode%3E00%3C%2FresponseCode%3E%3Cmessage%3E%26quot%3BAUTH + CODE%3A100955%26quot%3B%3C%2Fmessage%3E%3CauthCode%3E100955 %3C%2FauthCode%3E%3Camount%3E10000%3C%2Famount%3E%3Ccan%3E2506%3C%2Fcan%3E%3C%2FauthDetail%3E%3Csurcharge%3E%3CfundCode%3ECSRCH%3C%2FfundCode%3E%3Creference%3EA15009581 %3C%2Freference%3E%3Camount%3E175%3C%2F量%3E%3C%2Fsurcharge%3E%3Cmop%3E51%3C%2Fmop%3E%3Ccart%3E%3Citems%3E%3Citem%3E%3Creference%3EA7000%3C%2Freference%3E%3Creference2%3E1234%3C%2Freference2% 3E%3Ccan%3E2506%3C%2Fcan%3E%3CfundCode%3E8%3C%2FfundCode%3E%3Camount%3E10000%3C%2Famount%3E%3C%2Fitem%3E%3C%2Fitems%3E%3C%2Fcart%3E% 3C%2FportalRes%3E

如何進入C#中XmlDocument對象呢?

+0

能否請您指定付款門戶網站? –

+0

你只需要'URLDecode'它 – Liam

+0

誰低估了我? – markp3rry

回答

1

你需要調用Server.UrlDecode等解析XML內容。

1

只需在您的引用System.Web(如果沒有的話)..然後用HttpUtility.UrlDecode方法。

var result = HttpUtility.UrlDecode(input); 
2

如果狀態包含字符串:

var xml = new XmlDocument(); 
xml.LoadXml(HttpUtility.UrlDecode(status)); 

的數據(狀態)是LIK這樣的:

<portalRes xmlns="http://www.e-paycapita.com/portal"> 
    <requestID>7</requestID> 
    <reqStatus> 
    <statusCode>0</statusCode> 
    <message>Payment - Sale - Processing completed successfully.</message> 
    </reqStatus> 
    <authDetail> 
    <responseCode>00</responseCode> 
    <message>&quot;AUTH CODE:100955&quot;</message> 
    <authCode>100955</authCode> 
    <amount>10000</amount> 
    <can>2506</can> 
    </authDetail> 
    <surcharge> 
    <fundCode>CSRCH</fundCode> 
    <reference>A15009581</reference> 
    <amount>175</amount> 
    </surcharge> 
    <mop>51</mop> 
    <cart> 
    <items> 
     <item> 
     <reference>A7000</reference> 
     <reference2>1234</reference2> 
     <can>2506</can> 
     <fundCode>8</fundCode> 
     <amount>10000</amount> 
     </item> 
    </items> 
    </cart>