Пример #1
0
HRESULT LogSeriesProp::CreateElementSeries(IXMLDOMDocument *pDom, IXMLDOMElement *pe)
{
	IXMLDOMElement *pssub=NULL;
	HRESULT hr=S_OK;

	CreateAndAddElementNode(pDom, L"SName", L"\n\t\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->name);
	//pssub->Release();
	CreateAndAddElementNode(pDom, L"SType", L"\n\t\t\t", pe, &pssub);
	pssub->put_text(_bstr_t(typeid(*this).name()));

	CreateAndAddElementNode(pDom, L"color", L"\n\t\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->color);

	CreateAndAddElementNode(pDom, L"subRectTLX", L"\n\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->rect.TopLeft().x);

	CreateAndAddElementNode(pDom, L"subRectTLY", L"\n\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->rect.TopLeft().y);

	CreateAndAddElementNode(pDom, L"subRectBRX", L"\n\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->rect.BottomRight().x);

	CreateAndAddElementNode(pDom, L"subRectBRY", L"\n\t\t", pe, &pssub);
	pssub->put_text((_bstr_t)this->rect.BottomRight().y);

	return hr;	
}
Пример #2
0
HRESULT PlotWndPropText::CreateElementPlot(IXMLDOMDocument *pDom, IXMLDOMElement *pe)
{
    HRESULT hr=S_OK;
    IXMLDOMElement *pSeries=NULL;
    IXMLDOMElement *psub=NULL;
    CreateAndAddElementNode(pDom, L"WndName", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->GetName());
    CreateAndAddElementNode(pDom, L"WndNameIsSet", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->nameIsSet);
    //psub->Release();
    //no release
    CreateAndAddElementNode(pDom, L"WndType", L"\n\t\t", pe, &psub);
    psub->put_text(_bstr_t(typeid(*this).name()));
    CreateAndAddElementNode(pDom, L"WndFrameCount", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->frameCount);

    CreateAndAddElementNode(pDom, L"WndRectTLX", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->rect.TopLeft().x);

    CreateAndAddElementNode(pDom, L"WndRectTLY", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->rect.TopLeft().y);

    CreateAndAddElementNode(pDom, L"WndRectBRX", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->rect.BottomRight().x);

    CreateAndAddElementNode(pDom, L"WndRectBRY", L"\n\t\t", pe, &psub);
    psub->put_text((_bstr_t)this->rect.BottomRight().y);

    std::vector<SeriesProp *>::iterator iterSeries;
    for (iterSeries = this->seriesInPlotWndProp.begin();
            iterSeries !=this->seriesInPlotWndProp.end();
            iterSeries++)
    {
        CreateAndAddElementNode(pDom, L"Series", L"\n\t\t", pe, &pSeries);
        (*iterSeries)->CreateElementSeries(pDom,pSeries);
        pSeries->Release();
    }

    return hr;
}
Пример #3
-1
void dynamDOM()
{
    HRESULT hr = S_OK;
    IXMLDOMDocument *pXMLDom = NULL;
    IXMLDOMElement *pRoot = NULL;
    IXMLDOMElement *pNode = NULL;
    IXMLDOMElement *pSubNode = NULL;
    IXMLDOMDocumentFragment *pDF = NULL;

    BSTR bstrXML = NULL;
    VARIANT varFileName;
    VariantInit(&varFileName);

    CHK_HR(CreateAndInitDOM(&pXMLDom));

    // Create a processing instruction element.
    CHK_HR(CreateAndAddPINode(pXMLDom, L"xml", L"version='1.0'"));

    // Create a comment element.
    CHK_HR(CreateAndAddCommentNode(pXMLDom, L"sample xml file created using XML DOM object."));

    // Create the root element.
    CHK_HR(CreateElement(pXMLDom, L"root", &pRoot));

    // Create an attribute for the <root> element, with name "created" and value "using dom".
    CHK_HR(CreateAndAddAttributeNode(pXMLDom, L"created", L"using dom", pRoot));

    // Next, we will create and add three nodes to the <root> element.
    // Create a <node1> to hold text content.
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"node1", L"\n\t", pRoot, &pNode));
    CHK_HR(CreateAndAddTextNode(pXMLDom, L"some character data", pNode));
    SAFE_RELEASE(pNode);

    // Create a <node2> to hold a CDATA section.
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"node2", L"\n\t", pRoot, &pNode));
    CHK_HR(CreateAndAddCDATANode(pXMLDom, L"<some mark-up text>", pNode));
    SAFE_RELEASE(pNode);

    // Create <node3> to hold a doc fragment with three sub-elements.
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"node3", L"\n\t", pRoot, &pNode));

    // Create a document fragment to hold three sub-elements.
    CHK_HR(pXMLDom->createDocumentFragment(&pDF));

    // Create 3 subnodes.
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"subNode1", L"\n\t\t", pDF));
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"subNode2", L"\n\t\t", pDF));
    CHK_HR(CreateAndAddElementNode(pXMLDom, L"subNode3", L"\n\t\t", pDF));
    CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n\t", pDF));

    // Append pDF to <node3>.
    CHK_HR(AppendChildToParent(pDF, pNode));
    SAFE_RELEASE(pNode);

    // Add NEWLINE for identation before </root>.
    CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n", pRoot));
    // add <root> to document
    CHK_HR(AppendChildToParent(pRoot, pXMLDom));

    CHK_HR(pXMLDom->get_xml(&bstrXML));
    wprintf(L"Dynamically created DOM:\n%s\n", bstrXML);

    CHK_HR(VariantFromString(L"dynamDOM.xml", varFileName));
    CHK_HR(pXMLDom->save(varFileName));
    wprintf(L"DOM saved to dynamDOM.xml\n");

CleanUp:
    SAFE_RELEASE(pXMLDom);
    SAFE_RELEASE(pRoot);
    SAFE_RELEASE(pNode);
    SAFE_RELEASE(pDF);
    SAFE_RELEASE(pSubNode);
    SysFreeString(bstrXML);
    VariantClear(&varFileName);
}