1
我的應用程序使用htmlagility包。截至目前,我可以獲取表單上的所有輸入元素。問題是我通過ID獲取所有輸入元素。我試圖縮小它只給我一個表單的輸入元素,其中包含ID在每個輸入元素之前包含確切的內部文本標籤。如何在輸入元素之前獲取標籤的內部文本?
例子:
<label for="email">Email Address:</label>
<input type="text" class="textbox" name="email" id="email" maxlength="50" value="" dir="ltr" tabindex="1"
我想獲得具有程序標籤與「電子郵件地址」
內文字如何將我這個字輸入?
這是我的應用程序,通過ID獲取所有輸入元素。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim doc As HtmlDocument
Dim web As New HtmlWeb
doc = web.Load("http://shaggybevo.com/board/register.php")
Dim docNode As HtmlNode = doc.DocumentNode
Dim nodes As HtmlNodeCollection = docNode.SelectNodes("//input")
'SelectNodes takes a XPath expression
For Each node As HtmlNode In nodes
'Get all input elements by id
Dim id As String = node.GetAttributeValue("value", "id")
'print all input elements by id to form2 richtextbox
Form2.RichTextBox1.Text = Form2.RichTextBox1.Text & Environment.NewLine & id.ToString & name.ToString()
Form2.Show()
Next
End Sub
謝謝你們....我必須說,我一直在學習VB.NET了一會兒,迄今爲止這個論壇已經真棒......高興,我發現它..
WOW!我的一年是....再次感謝competent_tech。只要我得到足夠的問題來給代表....我會回來鉤你與適當的代表,你應該幫助我這麼多。 – 2012-01-01 19:29:33
好消息!我也發佈了一個答案你的問題:http://stackoverflow.com/questions/8380486/html-agility-pack-trying-to-get-inputs-getelementbyid-or-class-andputputin – 2012-01-01 19:45:55