Read html code --> textbox

xion911

Member
Joined
Aug 26, 2011
Messages
8
Programming Experience
Beginner
I am trying to get some text into a text box. If the code had an ID that I could find this would not be a problem, but all I can find is


<h4><span class="fn n"><span class="given-name">Joshua</span> <span class="additional-name">L.</span> <span class="family-name">Hendren</span></span></h4>

Is there a way to extract the name out of this? Should be Joshua L. Hendren.
 
You could get the InnerText of the H4 element, from GetElementsByTagName.
Using GetElementsByName is also possible to get each named element.
 
could you help me out with that?

TextBox1.Text = WebBrowser1.Document.GetElementsByTagName("given-name")

that by itself does not work "Value of type 'System.Windows.Forms.HtmlElementCollection' cannot be converted to 'String'."

I'm not really sure how GetElementsByTagName works.
 
TextBox1.Text = WebBrowser1.Document.GetElementsByTagName("H4")(0).InnerText
 
thanks, that works well. The code continues to:


<div class="adr"> <span class="street-address">2855 Star Route</span><br /><span class="locality">Chicago</span>, <span class="region">IL</span> <span class="postal-code">60631</span>
</div>

I don't see anything like h4 in there. Also, is there a way to break up the text into the three name parts? (first, middle, last)
 
is there a way to break up the text into the three name parts? (first, middle, last)
As I said, you can use the GetElementsByName method to get a named element. This method belongs to HtmlElementCollection class so if you want to look up elements by name from all elements in document you can use .Document.All collection.
 
Back
Top