要素へのアクセスはこんな感じと思われるが,Gettext の使い方がよくわからない.
BOOL ReadElement(MSXML::IXMLDOMElementPtr pElement,long indent)
{
CString tab = _T(“\t\t\t\t\t\t\t\t\t\t\t\t\t”) ;
CString lsp = tab.Left(indent) ;
if (pElement == NULL) { return FALSE ; }
MSXML::IXMLDOMNodeListPtr pNode = pElement->GetchildNodes() ;
{
CString node = LPCTSTR(pElement->GetnodeName()) ;
CString tagN = LPCTSTR(pElement->GettagName()) ;
CString text ;
// if (pNode->Getlength() == 0) {
text = LPCTSTR(pElement->Gettext()) ;
// }
cout << LPCTSTR(lsp) << LPCTSTR(node) << _T(“\t”) << LPCTSTR(text) << endl ;
for (int index=0 ; index<pNode->Getlength() ; index++) {
MSXML::IXMLDOMElementPtr child = pNode->Getitem(index) ;
ReadElement(child,indent+1) ;
}
}
return TRUE ;
}
BOOL TestXML (void)
{
…
if (pDoc->load(LPCTSTR(loadFile)) == VARIANT_TRUE) {
{
MSXML::IXMLDOMElementPtr root = pDoc->documentElement ;
ReadElement(root,0) ;
}
}
…
}