473,569 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get html to string

Hi all,

I want to have www.msdn.microsoft.com 's html code in a string ? What can i
do to have it?


Dec 23 '05 #1
3 15709
You can create WebRequest passing Url and Get webResponse .
Get ResponseStream from WebResponse and read it into a String

Still if you have problem , let me know


Dec 23 '05 #2
Hello ozulku_omer,

o> I want to have www.msdn.microsoft.com 's html code in a string ? What
o> can i do to have it?

// Address of URL
string URL = textBox1.Text;
// Get HTML data
WebClient client = new WebClient();
Stream data = client.OpenRead (URL);
StreamReader reader = new StreamReader(da ta);
string str = "";
str = reader.ReadLine ();

while( str != null)
Console.WriteLi ne(str);
str = reader.ReadLine ();
catch(WebExcept ion exp)
MessageBox.Show (exp.Message, "Exception" );
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Dec 23 '05 #3
Hi Omer,

Here is the Code for converting HTml into string

string result = string.Empty;

WebRequest wrq = WebRequest.Crea te(Url);
WebResponse wrs = wrq.GetResponse ();

StreamReader strdr = new StreamReader(wr s.GetResponseSt ream());
result = strdr.ReadToEnd ();


Dec 24 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: lkrubner | last post by:
I'd like to write a PHP script to be used from the command line on a Unix machine. I'd like for the script to put together a string, turn it into a web page, print it, then return control the command line. Obviously it is quite easy to make a string that is valid HTML and send it to the printer. The tough part is making look like a web page....
by: Dan Schumm | last post by:
I'm relatively new to regular expressions and was looking for some help on a problem that I need to solve. Basically, given an HTML string, I need to highlight certain words within the text of the string. I had it working somewhat, but ran into problems if one of the highlighted words could also be part of an HTML tag (such as 'Table' or...
by: Wouter vanEck | last post by:
Hi, I need to find a way to read a html type string from a database and add it to a placeholder control on the page and then I need to be able to populate the fields that were in that html string at run time. The html string may look like this "<table><tr><td>First Name</td><td><input name=_firstname runat=server id=_firstname...
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
by: Tim_Mac | last post by:
hi, i have a tricky problem and my regex expertise has reached its limit. i have read other posts on this newsgroup that pull out the plain text from a html string, but that won't work for me because i want to preserve the html, and replace some of the plain text. i basically want to show the user's search terms highlighted in the page,...
by: Just D. | last post by:
All, What's the simplest way to show my own HTML string on the ASPX page assuming that this page is just created using the wizard and it has nothing on it? We're free to use any control adding it to this page just to show this HTML string. I know that in some cases we can use .InnerHtml property of some controls to inject the HTML string...
by: Gabriella | last post by:
Hi, I have a textarea, where the user can enter any given string. He can also insert HTML tags, if he/she wishes. Once I obtain the textarea's string as HTML through form.body.innerHTML, I would like to figure if there's a certain HTML tag inside (like <img src...or any other). I can do it through form.body.value.indexOf("<img") != -1,...
by: csgraham74 | last post by:
Hi, I have a requirement in work that i give a person the ability to create a html document using a richt text editor. What i then want to do is save the HTML doct to my server & insert reference in a database so that i can retrieve the html document. Basically i dont have a clue how to convert a string in HTML format (taken from the...
by: eggie5 | last post by:
I want to use element.appendChild(child) on a string of HTML I have: html= '<div> <strong>Text</strong> </div>' However, since it's not an element (ie created with document.createElement) I can't use appendChild with my html string.
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hello, I'm having issues with writing html string to a bookmark in MS Word 2007. I have a richtextbox control which returns HTML string, I would like to take that string and put it into a MS Word document and formatted to HTML Tags. Is this possible? And if so, can you point me in the right direction. Thank you, Terry
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.