get a only string from soap Response in classic asp

谁说我不能喝 提交于 2019-12-24 08:55:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!