How to get a Dom tree in GeckoFX
4 answers
I know this is an old question, but someone might still find the answer.
GeckoNodeCollection nodes = geckoWebBrowser1.Document.GetElementsByName("*");
foreach(GeckoNode node in nodes)
{
//do whatever you need to do with the node ..
GeckoElement element = node as GeckoElement;
//..
}
+5
source to share
If you want to use XPath, you can try:
browser.LoadXml("<MyTag><div>helloworld</div></MyTag>");
var r = browser.Document.EvaluateXPath("//div");
Assert.AreEqual(1, r.GetNodes().Count());
so in the prev code:
GeckoElementCollection nodes = browser.Document.EvaluateXPath("//div").GetNodes();
foreach(GeckoNode node in nodes)
{
//do whatever you need to do with the node ..
GeckoElement element = node as GeckoElement;
//..
}
0
source to share