locked
How to get a html page?

    Question

  • Hey,

    sorry for this simple question. 

    I want to get the html content of a page as Platform::String^ .
    Hope you can help me. Maybe with a link or an example code.

    i managed it in a console application. But now i want it in metro style.

    Hope you can help me :)

    Best Regards

    Sunday, August 26, 2012 8:42 PM

Answers

  • Hello,

    As far as I know, there is no directly way to get the HTML source of WebView control. But the WebView can inject the script and get the result.

    Therefore, we can inject script in WsbView loadCompleted event.
    Please follow this sample code
    http://code.msdn.microsoft.com/windowsapps/XAML-WebView-control-sample-58ad63f7

    In scenarion1, SDKSample::WebViewControl::Scenario1::WebView1_LoadCompleted function.

    Add these codes

    Array<String^>^ strarr=ref new Array<String^>(1);
    strarr[0]="document.documentElement.outerHTML;";
    String^ html=WebView1->InvokeScript("eval",strarr);
     
    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Thursday, August 30, 2012 6:12 AM
    Monday, August 27, 2012 8:24 AM

All replies