Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xml and sql server 2k problem

9 views
Skip to first unread message

Dhananjay

unread,
Dec 7, 2006, 8:58:30 AM12/7/06
to
hello everyone
I have a problem with xml and sql server 2k.
first thing i have a website named this->
http://en.infosites.org/info/keyword.
when i am entering a value for keyword like this ->
http://en.infosites.org/info/value now when this page opens in
browser(IE or Mozila FF) it shows only xml tags with some text as
contents. now i have to save this in sql server 2k i have a table in
that i have field as xml tags. i want to save entire thing which i
displayed in browser.
how to proceed i dont know. if anyone has idea the plz share with me .
its urgent
Thanks
Dhananjay

Nicholas Paldino [.NET/C# MVP]

unread,
Dec 7, 2006, 11:30:07 AM12/7/06
to
Dhananjay,

Well, you would want to use the HttpWebRequest/HttpWebResponse classes
to get the contents of the site. Once you do that, you can get the response
stream from the HttpWebResponse to feed the XmlDocument class to load the
document.

Once you have that, it's a simple matter of using the classes in
System.Data.? (where ? is specific for your database) to insert the data.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Dhananjay" <dhanan...@yahoo.co.in> wrote in message
news:1165499910.8...@f1g2000cwa.googlegroups.com...

Dhananjay

unread,
Dec 8, 2006, 4:15:47 AM12/8/06
to
======================================================

hi Nicholas Paldino

i ahve passed this
public void page_load()
{
Uri uri = new Uri("http://de.wikipedia.org/wiki/indien");
if (uri.Scheme == Uri.UriSchemeHttp)
{
HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(uri);
req.Method = WebRequestMethods.Http.Get;
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new
StreamReader(res.GetResponseStream());
string tmp = sr.ReadToEnd();
res.Close();
this.txturl.Text = tmp;
}
}
but i have got error it is not opening this url. i have got problem in
webresponse it is showing null can u coorect and plz send me.

reply me asap
its urgent

Thanks
Dhananjay

Marc Gravell

unread,
Dec 8, 2006, 4:39:31 AM12/8/06
to
Random question; how does this relate to either xml or sqlserver?
The main problem that the page 403s; try adding a trailing slash...

However in 2.0 a better solution may be to use WebClient:

string html;
using (WebClient client = new WebClient()) {
html =
client.DownloadString(@"http://de.wikipedia.org/wiki/indien/");
}
this.txturl.Text = html;

Marc


Dhananjay

unread,
Dec 9, 2006, 1:21:46 AM12/9/06
to
=======================================================

hi marc

i have tried this code also which is provied by you but i have got
error
the error is
The remote server returned an error: (403) Forbidden. what sould i do
do you have any other solution let me know plz
its urgent Thanks Dhananjay

string html;
> using (WebClient client = new WebClient()) {
> html =
> client.DownloadString(@"http://de.wikipedia.org/wiki/indien/");
> }
> this.txturl.Text = html;

Thanks
Dhananjay

Marc Gravell

unread,
Dec 9, 2006, 4:10:59 PM12/9/06
to
Well I'll be jiggered! Case sensitivity. I know that the spec. allows
for this, but it is quite rare to see it in reality (for a simple GET,
at least) ;-p

Following works for me; I have tested it properly this time!
html = client.DownloadString(@"http://de.wikipedia.org/wiki/Indien");

Marc

0 new messages