SOL9 Sample: HTMLDocumentFromString
|
1 Screenshot
2 Source code
/*
* HTMLDocumentFromString.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2011/12/07
#include <sol/COMInitializer.h>
#include <sol/Locale.h>
#include <sol/html/HTMLDocument.h>
#include <sol/html/HTMLElement.h>
#include <sol/html/HTMLElementCollection.h>
int _tmain(int argc, _TCHAR* argv[])
{
COMInitializer initializer;
Locale locale;
try {
SOL::HTMLDocument document;
document.createDocument();
_bstr_t string = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=Shift_JIS'>"\
"<title>HTML Sample</title></head><body><h1>Hello world</h1><h2>こんにちは</h2><br>"\
"<a href='http://www.antillia.com'>Antillia.com</a></body></html>";
document.write(string);
document.close();
HTMLElement docElement = document.getDocumentElement();
_bstr_t docOuterHtml = docElement.getOuterHTML();
_tprintf(_T("Document::OuterHTML=[%s]\n\n"), (const TCHAR*)docOuterHtml);
_bstr_t docInnerHtml = docElement.getInnerHTML();
_tprintf(_T("Document::InnerHTML=[%s]\n\n"), (const TCHAR*)docInnerHtml);
HTMLElement body = document.getBody();
_bstr_t outerHtml = body.getOuterHTML();
_tprintf(_T("Body::OuterHTML=[%s]\n\n"), (const TCHAR*)outerHtml);
_bstr_t innerHtml = body.getInnerHTML();
_tprintf(_T("Body::InnerHTML=[%s]\n\n"), (const TCHAR*)innerHtml);
_bstr_t title = document.getTitle();
_tprintf(_T("title %s\n"), (const TCHAR*)title);
} catch (Exception& ex) {
ex.display();
} catch (HRESULT ) {
printf("Exception\n");
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.