如何获得字符串"response"来自"getxmlresponse"功能? [英] How to get the string "response" from "getxmlresponse" function?

查看:115
本文介绍了如何获得字符串"response"来自"getxmlresponse"功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从"getxmlresponse"函数获取字符串"response"以在另一个函数中使用?以及如何将字符串转换为xml以及如何将xml转换为数据库?

How to get the string "response" from "getxmlresponse" function to use in another function ? and how to convert string to xml and xml to database?

public string getxmlresponse(string ChkRequest)
   {
       string RequestURLString = " http://www.hotelspro.com/xf_3.0/hp_xml_request_parser.php?xml=" + ChkRequest;
       WebRequest wrequest = null;
       try
       {
           string Response = string.Empty;
           wrequest = WebRequest.Create(RequestURLString);
           Stream ResponseStrm = null;
           wrequest.Timeout = 0xea60;
           ResponseStrm = wrequest.GetResponse().GetResponseStream();
           StreamReader Reader = new StreamReader(ResponseStrm);
           try
           {
               Response = Reader.ReadToEnd();
           }
           catch
           {

           }
           return Response;
           ResponseStrm.Close();
           Reader.Close();

    }
       catch (Exception)
       { }
       return "";
   }

推荐答案

只需调用此方法即可获取字符串.无论您的请求ID是什么,都可以使用ChkRequest并获取Response字符串.

使用
XDocument.Parse将字符串解析为XML. ;)
Just call this method to get the string. Use ChkRequest whatever your request id would be and get the Response string.

Use
XDocument.Parse to parse the string into XML. ;)


这篇关于如何获得字符串"response"来自"getxmlresponse"功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆