Each web page loaded in the browser has its own document object. To access document object of loaded web page use the Browser.GetDocument()method. This method returnsDOMDocument instance that you can use to access document's properties and its child nodes. For example:

C#

DOMDocument document = browser.GetDocument();


VB.NET

Dim document As DOMDocument = browser.GetDocument()


If the web page contains frames (see IFRAME or FRAME), then each frame has its own document object. To access document object of a specified frame use theBrowser.GetDocument(long frameId) method. You can obtain theframeId from theBrowser.GetFramesIds() method. For example:

C#

foreach (long frameId in browser.GetFramesIds()) {
    DOMDocument frameDocument = browser.GetDocument(frameId);
}


VB.NET

For Each frameId As long In browser.GetFramesIds()
    Dim frameDocument As DOMDocument = browser.GetDocument(frameId)
Next



Having DOMDocumentinstance you can work with the document object and its DOM structure.


If web page isn't completely loaded or it doesn't have document, then the Browser.GetDocument() method returns null. So, before you invoke this method, make sure that web page is loaded completely.