Read xml Data from another website.

G

Guest

Hi All,

i need to read xml data from another website in asp.net. i have written some
code in classic asp that's working but i dont know how to write code for
asp.net.
i have written follwoing code in classic asp.

function NewZawyaSessionId
Dim strZSessionId, strURL, strUserName, strPass, strContent
Dim P,N
strUserName="user"
strPass="password"
strURL="https://www.zawya.com/clientsessionid/default.cfm?username=" &
strUserName & "&password=" & strPass
set xmlhttp=Server.CreateObject("Microsoft.XMLHTTP")
call xmlhttp.Open("POST", strURL, false)

on error resume next
call xmlhttp.Send("")
if err.number<>0 then
strContent="0"
else
strContent= xmlhttp.responseText
end if
end function

any help will be greatly appriciated :)

Thanks

Shahid
 
J

JuanCri

A quick try is to do this:

// Create request
HttpWebRequest request = (HttpWebRequest) WebRequest.Create
("http://www.juancri.com/");

// Create response
WebResponse response = request.GetResponse ();

// Create stream
Stream stream = response.GetResponseStream ();

// Create reader
StreamReader reader = new StreamReader (stream);

// Get text
String text = reader.ReadToEnd ();

// Close all
reader.Close ();
stream.Close ();
response.Close ();

// Create XmlDocument
XmlDocument xml = new XmlDocument ();

// Load from text
xml.LoadXml (text);



Juan C. Olivares
www.juancri.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top