Groups | Blog | Home
all groups > dotnet xml > june 2006 >

dotnet xml : Read xml from a password protected site


David Thielen
6/4/2006 6:59:02 PM
Hi;

If I need to parse an xml file from a password protected site - like:
XmlReader xmlReader = XmlReader.Create("http://www.cia.gov/AgentList.xml",
readerSettings);

How do I pass in the username/password so it can get the url?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
v-kevy NO[at]SPAM online.microsoft.com
6/5/2006 12:00:00 AM
Hi Dave,

This depends on what kind of authentication the server is requiring. Is it
using forms authentication or just basic ones?

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
David Thielen
6/5/2006 10:27:03 AM
Hi;

It could be anything. We let users enter a url and then we go to pull the
xml from the url they gave us.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
Peter Flynn
6/5/2006 8:49:56 PM
[quoted text, click to view]

http://hhoover:crossdress@www.cia.gov/AgentList.html

///Peter
v-kevy NO[at]SPAM online.microsoft.com
6/6/2006 12:00:00 AM
Hi Dave,

In this case, you need to use XmlDocument class, to get the xml from that
URL. There is a property named XmlResolver, which you can specify an
XmlUrlResolver object. Then you can specify the Credentials for that
resolver. For more information, you can check the following link:

http://msdn2.microsoft.com/en-us/library/system.xml.xmlurlresolver.credentia
ls.aspx

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
David Thielen
6/6/2006 6:32:02 AM
I think that's the one for the fbi, not the cia <g>.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
David Thielen
6/6/2006 7:31:01 AM
that's it - thanks - dave

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
v-kevy NO[at]SPAM online.microsoft.com
6/7/2006 2:08:37 AM
You're welcome.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
David Thielen
7/21/2006 4:35:01 PM
thank you

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



[quoted text, click to view]
Natrajan
7/21/2006 11:28:21 PM

[quoted text, click to view]

HttpWebRequest myHttpWebRequest;
NetworkCredential netCred = new NetworkCredential("username", "password", "domainname");
myHttpWebRequest = (HttpWebRequest)WebRequest.Create(protectedWebSiteURL);
myHttpWebRequest.Credentials = netCred;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream data = myHttpWebResponse.GetResponseStream(); System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader reader = new StreamReader(data, encode);
FileStream fs = File.Create(Server.MapPath(fileName));
StreamWriter sw = new StreamWriter(fs);
sw.Write(reader.ReadToEnd());
sw.Close();
fs.Close();

AddThis Social Bookmark Button