SOL9 Sample: HTMLDocumentFromFile

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * HTMLDocumentFromFile.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2012/02/20

#include <sol/COMInitializer.h>
#include <sol/Locale.h>
#include <sol/Application.h>
#include <sol/html/HTMLDocument.h>
#include <sol/html/HTMLElement.h>

void _tmain(int argc, _TCHAR* argv[])
{
  if (argc != 2) {
    _tprintf(_T("Usage:%s localHTMLFile\n"), argv[0]);
    return;
  }
  _bstr_t url = argv[1];

  COMInitializer initializer;

  Locale locale;

  try {
    SOL::HTMLDocument document;
    //Create an HTMLDocument
    document.createDocument();

    //Load a content of the local file of url into the document
    document.loadFromFile(url);

    //Get a DocumentElement of the document.
    SOL::HTMLElement docElement = document.getDocumentElement();
  
    //Get an outerHTML of the element.
    _bstr_t docHTML = docElement.getOuterHTML();

    _tprintf(_T("%s\n"), (const TCHAR*)docHTML);

  } catch (Exception& ex) {
    ex.printf();
  } catch (HRESULT hr) {
    printf("Exception hr=%x\n", hr);
  }
}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.