The simplest way to view xml data in browser is to use browser's build-in support for showing xml.
Below is a simple demo.
protected void Button1_Click(object sender, EventArgs e)
{
WebRequest request = WebRequest.Create("http://www.whoisxmlapi.com/whoisserver/WhoisService");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Response.Clear(); // remove other data
Response.ContentType = "text/xml";// set content type to text/xml to show xml data
Response.Write(responseFromServer); // write the xml
Response.End(); // end the response
reader.Close();
dataStream.Close();
response.Close();
}
The result.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
element.Element get single element with the specified tag name, and then you could get the text in it through Value property.
element.Elements get all element with the specified tag name, and then you could get all element in it and then get their values.
You could then show these values in a gridview.
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
The Problem briefly discussed in video please have a look :( actually i am receiving the data perfectly but cant show it in my webpage in organized way
can u please code me in details please cause i am getting unhandled situation while trying your code. Please do me a favour just implement the api create a webform and pass the data into table and help me with that code
Please do me a favour just implement the api create a webform and pass the data into table and help me with that code
Wow. Just wow. And how much per hour are you offering? Aren't you being paid for this?
Mark all posts that give the desired result the answer. If you only mark the last that gave you clarification because you misread an earlier post others will be confused. Some of us are here to help others and our point to post ratio matters.
i am making it as my final year project for graduation. Basically, i am a network engineer. but university authority force me to do software development. So thats why i am newbie in Dot net platform.
And I find all the data could be found in the rowText node, so if you want to show it in an organized way, you could refer to the code below.
XElement element = XElement.Load(Server.MapPath("/xmlDemo/domainData.xml"));
IEnumerable<XElement> xElements = element.Descendants("rawText");
StringBuilder stringBuilder = new StringBuilder();
foreach (XElement item in xElements)
{
stringBuilder.Append( item.Value.Replace("\n", "<br/>"));
}
Response.Write(stringBuilder.ToString());
The result.
If you want a single node's value , you could refer to the link below.For example, if you want to get registrant node's organization value , you could write
// < registrant >
// < organization > Google LLC </ organization >
// < state > CA </ state >
// < country > UNITED STATES </ country >
// < countryCode > US </ countryCode >
// < rawText > Registrant Organization: Google LLC
//Registrant State/ Province: CA
// Registrant Country: US </ rawText >
// </ registrant >
string orgainization = element.Descendants("registrant").First().Element("organization").Value;
Best regards,
Ackerly Xu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
7 Posts
I want to show Raw XML code to aspx web page with design
Apr 21, 2019 03:12 PM|samprit chakraborty|LINK
Hi,
Recently i implement a api from WHOISAPI. But i am receiving raw xml data which is showing in my webapps as raw one.
Here is the screeshot please see: CLICK HERE
I want to show it as tree base. OR in any format that can ready easily as a webpage Like this.
Click here : Click Here
That is my code in web apps
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;
}
}
}
Contributor
3460 Points
1300 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 23, 2019 03:27 AM|Ackerly Xu|LINK
Hi samprit chakraborty,
The simplest way to view xml data in browser is to use browser's build-in support for showing xml.
Below is a simple demo.
The result.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
7 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 23, 2019 02:56 PM|samprit chakraborty|LINK
Hi,
Thanks for your awesome support. I want to show the XML data within a table . Like this : http://prntscr.com/nftovx
How can i do it ?
Contributor
3460 Points
1300 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 24, 2019 01:58 AM|Ackerly Xu|LINK
Hi samprit chakraborty,
It depends on the structure of your xml.
You could retrieve data trough XElement or XmlDocument api.
For example , about XElement, you could
element.Element get single element with the specified tag name, and then you could get the text in it through Value property.
element.Elements get all element with the specified tag name, and then you could get all element in it and then get their values.
You could then show these values in a gridview.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
7 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 29, 2019 06:24 PM|samprit chakraborty|LINK
Hi,
The Problem briefly discussed in video please have a look :( actually i am receiving the data perfectly but cant show it in my webpage in organized way
Video Link : https://youtu.be/p756AUAQocw
Member
1 Points
7 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 29, 2019 07:13 PM|samprit chakraborty|LINK
can u please code me in details please cause i am getting unhandled situation while trying your code. Please do me a favour just implement the api create a webform and pass the data into table and help me with that code
Contributor
7008 Points
2162 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 29, 2019 07:18 PM|ryanbesko|LINK
Member
1 Points
7 Posts
Re: I want to show Raw XML code to aspx web page with design
Apr 30, 2019 05:49 PM|samprit chakraborty|LINK
i am making it as my final year project for graduation. Basically, i am a network engineer. but university authority force me to do software development. So thats why i am newbie in Dot net platform.
Contributor
3460 Points
1300 Posts
Re: I want to show Raw XML code to aspx web page with design
May 02, 2019 05:54 AM|Ackerly Xu|LINK
Hi samprit chakraborty,
I have visisted whoisxml api and use this link's xml as a reference.
https://whoisapi.whoisxmlapi.com/whois/google.com?format=XML
And I find all the data could be found in the rowText node, so if you want to show it in an organized way, you could refer to the code below.
The result.
If you want a single node's value , you could refer to the link below.For example, if you want to get registrant node's organization value , you could write
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
7 Posts
Re: I want to show Raw XML code to aspx web page with design
May 02, 2019 05:26 PM|samprit chakraborty|LINK
Thanks a lot man ! finaly i get my answer. All the best bro ! You are really helpfull ! Thanks to all of you guys.