2012-04-27 70 views
1

SOAP响应一个唯一的字符串我有写XML代码的请求的Web服务 我越来越喜欢适当的反应:得到在传统的ASP

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <getOrderFileResponse xmlns="http://www.edocbuilder.com/"> 
     <getOrderFileResult>**string**</getOrderFileResult> 
    </getOrderFileResponse> 
    </soap:Body> 
</soap:Envelope> 

我想从这个响应

唯一字符串你能请帮我解决?

+0

您正在使用什么语言? – Cheeso 2012-05-01 00:30:58

+0

使用'Instr'和'Mid' – 2012-05-02 01:03:08

回答

2

我可以提供这个功能可以轻松地提取在传统的ASP值:

function findStringBetween(s_string, s_pre, s_post, n_options) 
    ' n_options: 
    ' 1: IGNORE case in the search 
    dim a, b 
    ' init 
    findStringBetween = "" 
    ' find pre-word 
    a = instr(1, s_string, s_pre, n_options) 
    if a>0 then 
    a = a + len(s_pre) 
    b = instr(a, s_string, s_post, n_options) 
    if b>0 and not (s_post = "") then 
     findStringBetween = mid(s_string, a, b-a) 
    else 
     findStringBetween = mid(s_string, a) 
    end if 
    end if 
end function 

包括这在你的代码,那么你可以使用它像这样:

dim my_value 
my_value = findStringBetween(s_soap_response, "<getOrderFileResult>", "</getOrderFileResult>", 0)