Search code examples
c#domdomdocumentmonomac

Cocoa getting input data from DOMDocument


I'm trying to get data from the DOM from a document loaded into a Cocoa WebView control but it seems like the element's value is empty. I'm using MonoMac. The code I'm using (C#) is below:

var document = WebBrowser.MainFrameDocument;

if (document != null)
{
    // GetAllChildren is a recursive extension function that iterates through a DomNode's
    // ChildNodes property and returns a list of all of them
    var textareaElements = document.GetAllChildren().OfType<DomHtmlElement>().Where(node => node.Name.Equals("TEXTAREA"));
    foreach (var textarea in textareaElements)
    {
        var value = textarea.Value; // this is always ""
    }
}

Do I need to do something to make sure the DOM reference I have to has the data entered into the webpage?


Solution

  • This appears to be a bug in the MonoMac implementation: https://bugzilla.xamarin.com/show_bug.cgi?id=7754

    UPDATE: There is an active pull request that fixes this issue: https://github.com/mono/monomac/pull/109