SOL9 Sample: XMLDOMNodeList
|
1 Screenshot
2 Source code
/*
* XMLDOMNodeList.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/04/23
// 2011/01/28 Updated
// Sample program to use XMLDocument::getElementsByTagName() method
// Run as XMLNodeList.exe Application.xml
#include <sol/COMInitializer.h>
#include <sol/Locale.h>
#include <sol/xml/XMLDOMDocument.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc !=2) {
_tprintf(_T("Usage:\n%s Application.xml\n"), argv[0]);
return;
}
if (GetFileAttributes(argv[1]) == 0xffffffff) {
_tprintf(_T("File not found %s\n"), argv[1]);
return;
}
Locale locale;
COMInitializer comInitializer;
try {
XMLDOMDocument xmlDocument;
xmlDocument.open(argv[1]);
_bstr_t xml = xmlDocument.getXML();
_tprintf(_T("XML:\n%s\n"), (const TCHAR*)xml);
{
const TCHAR* name = _T("LayoutManager");
_tprintf(_T("1 xmlDocument.getElementsByTagName(\"%s\")\n"), name);
XMLDOMNodeList nodeList = xmlDocument.getElementsByTagName(name);
_tprintf(_T("2 OK, getElementsByTagName\n"));
nodeList.dump();
}
{
const TCHAR* name = _T("Button");
_tprintf(_T("4 xmlDocument.getElementsByTagName(\"%s\")\n"), name);
XMLDOMNodeList nodeList = xmlDocument.getElementsByTagName(name);
_tprintf(_T("5 OK, getElementsByTagName\n"));
nodeList.dump();
}
} catch (HRESULT hr) {
_tprintf(_T("Exception 0x%x\n"), hr);
} catch (Exception& ex) {
ex.printf();
} catch (...) {
_tprintf(_T("Exception %x\n"), GetLastError());
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.