问题
I have write xml code for requesting web service I am getting proper response like:
<?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>
I want only string from this response
Can you please help me out?
回答1:
I can offer this function to easily extract the value in classic 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
Include this in your code, then you can use it like this:
dim my_value
my_value = findStringBetween(s_soap_response, "<getOrderFileResult>", "</getOrderFileResult>", 0)
来源:https://stackoverflow.com/questions/10351460/get-a-only-string-from-soap-response-in-classic-asp