Export (0) Print
Expand All

IQueryRecentWinSATAssessment::XML property

[IQueryRecentWinSATAssessment::XML may be altered or unavailable for releases after Windows 8.1.]

Retrieves data from the XML assessment document by using the specified XPath. The query is run against the most recent formal assessment in the WinSAT data store.

This property is read-only.

Syntax


HRESULT get_XML(
  [in]  BSTR xPath,
  [in]  BSTR namespaces,
  [out] IXMLDOMNodeList **ppDomNodeList
);

Property value

An IXMLDOMNodeList interface that contains the results of the XPath query. Use this interface to retrieve nodes from the results collection.

Error codes

Name/valueMeaning
S_OK

Successfully ran the XPath query. You can use the IXMLDOMNodeList::get_length method to determine whether the query returned results.

WINSAT_ERROR_NO_RESULTS
0x80040012

The WinSAT data store does not contain results for any formal assessments.

E_UNEXPECTED

An unexpected internal error occurred during XML loading. To retrieve extended error information, call the GetErrorInfo function.

E_FAIL

An error occurred during the XPath selection, which is typically the result of a malformed XPath.

Remarks

You can use this method to retrieve details of the assessment that are not available in the summary information provided through the API. For details about all the information available in an assessment, see the WinSAT Schema.

The first formal assessment is run when you initially set up your computer. The initial assessment will remain in the data store for the life of the data store. The WinSAT data store can contain up to 100 formal assessments. When the store reaches capacity, WinSAT will delete the oldest assessment (but not the initial assessment) in the data store for each new formal assessment that is run.

The WinSAT data store contains only formal assessments. If you want to retrieve assessment data from ad hoc assessments, you must save the results to an XML file when you run the assessment (see the -xml command-line argument for details). You can then use the members of the IXMLDOMDocument2 interface to query data from the ad hoc assessment.

To retrieve summary information about the assessment, call the IQueryRecentWinSATAssessment::get_Info method. To retrieve summary information for a subcomponent of the assessment, call the IProvideWinSATResultsInfo::GetAssessmentInfo method.

Examples

The following example shows how to use an XPath query to get data from the most recent formal assessment.


#include <windows.h>
#include <stdio.h>
#include <winsatcominterfacei.h>

#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")

void main(void)
{
    HRESULT hr = S_OK;
    IQueryRecentWinSATAssessment* pAssessment;
    IXMLDOMNodeList* pNodes = NULL;
    IXMLDOMNode* pNode = NULL;
    long NodeCount = 0;
    BSTR bstrXPath = SysAllocString(L"WinSAT/TotalRunTime/Description");
    BSTR bstrTime = NULL;

    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

    // Get an instance to the most recent formal assessmenet.
    hr = CoCreateInstance(__uuidof(CQueryWinSAT),
        NULL,
        CLSCTX_INPROC_SERVER,
        __uuidof(IQueryRecentWinSATAssessment),
        (void**)&pAssessment);

    if (FAILED(hr))
    {
        wprintf(L"Failed to create an instance of IQueryRecentWinSATAssessment. Failed with 0x%x.\n", hr);
        goto cleanup;
    }

    // Query the assessment for the nodes that match the XPath expression.
    hr = pAssessment->get_XML(bstrXPath, NULL, &pNodes);
    if (FAILED(hr))
    {
        wprintf(L"pAssessment->get_XML failed with 0x%x.\n", hr);
        goto cleanup;
    }

    hr = pNodes->get_length(&NodeCount);
    wprintf(L"There were %d results found for the XPath query.\n\n", NodeCount);

    // Loop through the results.
    for (long i = 0; i < NodeCount; i++)
    {
        hr = pNodes->nextNode(&pNode);
        if (pNode)
        {
            hr = pNode->get_text(&bstrTime);
            if (S_OK == hr)
            {
                wprintf(L"Total runtime of the assessment: %s\n", bstrTime);
                SysFreeString(bstrTime);
            }
            else
            {
                wprintf(L"pNode->get_text failed with 0x%x.\n", hr);
                goto cleanup;
            }

            pNode->Release();
            pNode = NULL;
        }
        else
        {
            wprintf(L"pNodes->nextNode failed with 0x%x.\n", hr);
            goto cleanup;
        }
    }

cleanup:

    if (pAssessment)
        pAssessment->Release();

    if (pNodes)
        pNodes->Release();

    if (bstrXPath)
        SysFreeString(bstrXPath);

    CoUninitialize();
}


Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

None supported

End of client support

Windows 8.1

End of server support

None supported

Header

Winsatcominterfacei.h

DLL

Winsatapi.dll

See also

IInitiateWinSATAssessment
IQueryAllWinSATAssessments::AllXML
IQueryRecentWinSATAssessment

 

 

Community Additions

ADD
Show:
© 2015 Microsoft