我想在基于C#Web的页面中以格式化的方式显示来自API的原始XML数据

时间:2019-04-21 15:44:48

标签: asp.net xml api

我无法在Web应用程序中以格式化的方式显示XML数据。我收到的数据显示为http://prntscr.com/newpno

但是我想在C#中以格式化的方式很好地显示它 请帮忙 这是代码

公共局部类TotalWebReport:System.Web.UI.Page     {         受保护的void Page_Load(对象发送者,EventArgs e)         {

    }
    public  string DOMAIN = "www. .com";
    public  string PASSWORD = "";
    public  string USERNAME = " ";
    protected void btnScan_Click(object sender, EventArgs e)
    {
        try
        {
            DOMAIN = txtUrl.Text;
            string url = "http://www.whoisxmlapi.com/whoisserver/WhoisService?"
                               + $"domainName={DOMAIN}&username={USERNAME}"
                               + $"&password={PASSWORD}";
            string whoisData = string.Empty;

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            //StreamReader reader=StreamReader.Null;
            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (StreamReader reader = new StreamReader(stream))
            {
                whoisData = reader.ReadToEnd();
            }
            //    reader = new StreamReader(stream);
            //XmlReader xmlreader = XmlReader.Create(reader);
            //while (xmlreader.Read())
            //{
            //    whoisData=xmlreader.Value;
            //}
            //xmlreader.Close();
            pResult.InnerText = whoisData;
        }
        catch (Exception ex)
        {

            throw;
        }

我想以网站页面的格式获取代码!

[1]: https://i.stack.imgur.com/KVkGP.png

0 个答案:

没有答案