Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur

29 Aralık 2009 Salı

Bir web sayfasının dom yapısının TreeView da gösterimi


Form1.cs

using System;
using System.Linq;
using System.Windows.Forms;

namespace wfTreeWebBrowser
{
public partial class Form1 : Form
{
public Form1() { InitializeComponent(); }

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { }

private void fTamamlandi()
{
treeView1.Nodes.Add("0", "ROOT");
for (int i = 0; i < wb.Document.All.Count; i++)
{
treeView1.Nodes["0"].Nodes.Add((++count).ToString(), wb.Document.All[i].TagName);
if (wb.Document.All[i].All.Count>0)
{
fParse(wb.Document.All[i], count.ToString());
}
}
}

private int count;
private void fParse(HtmlElement he, string key)
{
for (int i = 0; i < he.All.Count; i++)
{
if (he.All[i].All.Count>0)
{
treeView1.Nodes.Find(key,true).First().Nodes.Add((++count).ToString(), count + " * " + he.All[i].TagName);
fParse(he.All[i], count.ToString());
}
else
{
treeView1.Nodes.Find(key,true).First().Nodes.Add((++count).ToString(), count + " - " + he.All[i].OuterHtml);
}

}
}

private void button1_Click(object sender, EventArgs e)
{
fTamamlandi();
}
}
}




Form1.Designer.cs

namespace wfTreeWebBrowser
{
partial class Form1
{
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.wb = new System.Windows.Forms.WebBrowser();
this.treeView1 = new System.Windows.Forms.TreeView();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// wb
//
this.wb.Location = new System.Drawing.Point(12, 62);
this.wb.MinimumSize = new System.Drawing.Size(20, 20);
this.wb.Name = "wb";
this.wb.Size = new System.Drawing.Size(250, 250);
this.wb.TabIndex = 0;
this.wb.Url = new System.Uri("http://localhost/", System.UriKind.Absolute);
this.wb.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted);
//
// treeView1
//
this.treeView1.Location = new System.Drawing.Point(268, 12);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(290, 300);
this.treeView1.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(250, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Ağaç yapısını çıkar";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(570, 464);
this.Controls.Add(this.button1);
this.Controls.Add(this.treeView1);
this.Controls.Add(this.wb);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.WebBrowser wb;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.Button button1;
}
}

Hiç yorum yok: