Example #1
0
bool CHelpDB::GetItemElement(CTSTRING& _sAlias, MSXML::IXMLDOMElementPtr& Out, bool bCreate)
{
    bool r = false;
    TSTRING sXPath;
    MSXML::IXMLDOMNodePtr Node;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // this will look something like MSG[@ALIAS="hithere"]
    sprintf(sXPath, TAG_MSG _T("[@") TAG_ALIAS _T("=\"%s\"]"), sAlias.c_str());

    try
    {
        Node = m_root->selectSingleNode(_bstr_t(sXPath.c_str()));

        if((Node == NULL) && (bCreate == true))
        {
            MSXML::IXMLDOMElementPtr NewEl;
            MSXML::IXMLDOMNodePtr NewNode;

            NewEl = m_doc->createElement("MSG");
            NewEl.QueryInterface(__uuidof(MSXML::IXMLDOMNode), &NewNode);
            Node = m_root->appendChild(NewNode);
        }

        if(Node != NULL)
        {
            Node.QueryInterface(__uuidof(MSXML::IXMLDOMElement), &Out);
            r = true;
        }
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error());
        g_pLog->msg(_T("CHelpDB::GetItemElement(%s)"), _sAlias.c_str());
    }

    return r;
}
Example #2
0
bool CMessageEnum::Next(CHelpMessage& nfo)
{
    bool r = false;
    MSXML::IXMLDOMNodePtr Node;
    MSXML::IXMLDOMElementPtr Element;

    try
    {
        Node = m_list->nextNode();
        Node.QueryInterface(__uuidof(MSXML::IXMLDOMElement), &Element);

        r = m_pOwner->ElementToStruct(nfo, Element);
    }
    catch(_com_error&)
    {
        g_pLog->msg(_T("CMessageEnum::Next COM ERROR"));
    }
    catch(...)
    {
    }

    return r;
}