本文整理汇总了C++中msxml2::IXMLDOMElementPtr::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMElementPtr::setAttribute方法的具体用法?C++ IXMLDOMElementPtr::setAttribute怎么用?C++ IXMLDOMElementPtr::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMElementPtr
的用法示例。
在下文中一共展示了IXMLDOMElementPtr::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LibDir
void CALLBACK LibDir(PPBORCA_DIRENTRY pEntry, void * lpData)
{
MSXML2::IXMLDOMElementPtr childs((MSXML2::IXMLDOMElement *) lpData);
MSXML2::IXMLDOMElementPtr object = childs->ownerDocument->createElement("object");
object->setAttribute(_bstr_t("name"), _bstr_t(pEntry->lpszEntryName));
object->setAttribute(_bstr_t("comment"), _bstr_t(pEntry->szComments));
char lsnumber[30] = {0};
itoa(pEntry->otEntryType, lsnumber, 10);
object->setAttribute(_bstr_t("type"), _bstr_t(lsnumber));
object->setAttribute(_bstr_t("typename"),
_bstr_t(orca.convertObjectType(pEntry->otEntryType)));
itoa(pEntry->lEntrySize, lsnumber, 10);
object->setAttribute(_bstr_t("size"), _bstr_t(lsnumber));
tm *ptime = localtime(&pEntry->lCreateTime);
strftime(lsnumber, sizeof(lsnumber), "%d.%m.%y %H:%M:%S", ptime);
object->setAttribute(_bstr_t("createtime"), _bstr_t(lsnumber));
childs->appendChild(object);
object = NULL;
}
示例2: sizeof
bool CPbl2XML::Convert(MSXML2::IXMLDOMElementPtr &library, _bstr_t &path)
{
MSXML2::IXMLDOMElementPtr childnode = library->ownerDocument->
createElement("childs");
char buffer[256] = {0};
int iResult = m_orca.LibraryDirectory((char *) path,
buffer, sizeof(buffer), LibDir, (LPVOID) childnode.GetInterfacePtr());
if(iResult != PBORCA_OK) {
CString msg; msg.Format("FAILED: LibraryDirectory(...) : %s", (char *) path);
log.write(msg);
childnode = NULL;
return false;
}
_bstr_t xpath("childs");
MSXML2::IXMLDOMNodeListPtr childlist = library->selectNodes(xpath);
if(childlist->length > 0) {
library->replaceChild(childnode, childlist->item[0]);
} else {
library->appendChild(childnode);
}
// сохраняем значение комментария библиотеки
library->setAttribute(_bstr_t("comment"), _bstr_t(buffer));
return true;
}
示例3: SendMessageToCad
// 向CAD窗口发送命令
void SendMessageToCad(CString& strCommand, CStringArray& strParamArray)
{
MSXML2::IXMLDOMDocumentPtr lpDocument;
long hr = lpDocument.CreateInstance(__uuidof(DOMDocument));
if ( FAILED(hr) )
_com_raise_error(hr);
MSXML2::IXMLDOMProcessingInstructionPtr lpInstruction = lpDocument->createProcessingInstruction("xml","version='1.0' encoding='GB2312'");
lpDocument->appendChild(lpInstruction);
MSXML2::IXMLDOMElementPtr lpRoot = lpDocument->createElement(LPCTSTR("root"));
lpDocument->appendChild(lpRoot);
// 数据类型:命令或数据
MSXML2::IXMLDOMElementPtr lpCommand = lpDocument->createElement("command");
lpCommand->setAttribute("name", _variant_t(strCommand));
lpRoot->appendChild(lpCommand);
// 参数列表
for (int i=0; i<strParamArray.GetSize(); i++)
{
CString strParam = strParamArray.GetAt(i);
CString strName = strParam.Left(strParam.Find('='));
CString strValue = strParam.Right(strParam.GetLength()-strParam.Find('=')-1);
MSXML2::IXMLDOMElementPtr lpParam = lpDocument->createElement("param");
lpParam->setAttribute("name", _variant_t(strName));
lpParam->setAttribute("value", _variant_t(strValue));
lpCommand->appendChild(lpParam);
}
CString strXML = (LPCTSTR)(lpDocument->xml);
// OutputDebugString(lpDocument->xml);
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = strXML.GetLength()+1;
cds.lpData = (void*)strXML.GetBuffer(0);
strXML.ReleaseBuffer();
::SendMessage(acedGetAcadFrame()->m_hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
示例4: CreateStudyNode
static HRESULT CreateStudyNode(DcmDirectoryRecord *studyRec, MSXML2::IXMLDOMElementPtr &patient, MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
MSXML2::IXMLDOMElementPtr study = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Study", "http://www.weasis.org/xsd");
if(study == NULL) return CO_E_NOT_SUPPORTED;
const char *buff = NULL, *studyUID = NULL;
if(studyRec->findAndGetString(DCM_StudyInstanceUID, studyUID).bad()) return CO_E_NOT_SUPPORTED;
else study->setAttribute("StudyInstanceUID", studyUID);
if(studyRec->findAndGetString(DCM_StudyDate, buff).bad()) return CO_E_NOT_SUPPORTED;
else study->setAttribute("StudyDate", buff);
if(studyRec->findAndGetString(DCM_StudyTime, buff).good()) study->setAttribute("StudyTime", buff);
if(studyRec->findAndGetString(DCM_StudyID, buff).good()) study->setAttribute("StudyID", buff);
if(studyRec->findAndGetString(DCM_AccessionNumber, buff).good()) study->setAttribute("AccessionNumber", buff);
if(studyRec->findAndGetString(DCM_StudyDescription, buff).good()) study->setAttribute("StudyDescription", buff);
if(studyRec->findAndGetString(DCM_ReferringPhysiciansName, buff).good()) study->setAttribute("ReferringPhysicianName", buff);
patient->appendChild(study);
DcmDirectoryRecord *seriesRec = NULL;
while(seriesRec = studyRec->nextSub(seriesRec))
{
if(seriesRec->getRecordType() != ERT_Series) continue;
CreateSeriesNode(seriesRec, study, pXMLDom, studyUID);
}
return S_OK;
}
示例5: CreateInstanceNode
static HRESULT CreateInstanceNode(DcmDirectoryRecord *instanceRec, MSXML2::IXMLDOMElementPtr &series, MSXML2::IXMLDOMDocumentPtr &pXMLDom, const char *studyUID, const char *seriesUID)
{
MSXML2::IXMLDOMElementPtr instance = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Instance", "http://www.weasis.org/xsd");
if(instance == NULL) return CO_E_NOT_SUPPORTED;
const char *buff = NULL, *instanceUID = NULL, *transferSyntax = NULL;
if(instanceRec->findAndGetString(DCM_ReferencedSOPInstanceUIDInFile, instanceUID).bad()) return CO_E_NOT_SUPPORTED;
else instance->setAttribute("SOPInstanceUID", instanceUID);
if(instanceRec->findAndGetString(DCM_ReferencedTransferSyntaxUIDInFile, transferSyntax).bad()) return CO_E_NOT_SUPPORTED;
else instance->setAttribute("TransferSyntaxUID", transferSyntax);
char url[512];
sprintf_s(url, "getindex.exe?requestType=WADO&studyUID=%s&seriesUID=%s&objectUID=%s&contentType=application%%2Fdicom&transferSyntax=%s",
studyUID, seriesUID, instanceUID, transferSyntax);
instance->setAttribute("DirectDownloadFile", url);
if(instanceRec->findAndGetString(DCM_InstanceNumber, buff).good()) instance->setAttribute("InstanceNumber", buff);
series->appendChild(instance);
return S_OK;
}
示例6: CreateWADO
static HRESULT CreateWADO(MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
HRESULT hr = pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument30));
if (FAILED(hr)) return hr;
pXMLDom->preserveWhiteSpace = VARIANT_FALSE;
pXMLDom->async = VARIANT_FALSE;
MSXML2::IXMLDOMElementPtr wado;
MSXML2::IXMLDOMProcessingInstructionPtr pi;
pi = pXMLDom->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"GBK\"");
if (pi != NULL)
{
pXMLDom->appendChild(pi);
pi.Release();
}
pi = pXMLDom->createProcessingInstruction("xml-stylesheet", "type=\"text/xml\" href=\"../xslt/wadolist.xsl\"");
if (pi != NULL)
{
pXMLDom->appendChild(pi);
pi.Release();
}
wado = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "wado_query", "http://www.weasis.org/xsd");
wado->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
wado->setAttribute("requireOnlySOPInstanceUID", "false");
pXMLDom->appendChild(wado);
wado->setAttribute("wadoURL", "http://localhost/pacs/cgi-bin/");
/*
MSXML2::IXMLDOMElementPtr httpTag;
httpTag = pXMLDom->selectSingleNode("/wado_query/httpTag");
if( ! httpTag )
{
httpTag = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "httpTag", "http://www.weasis.org/xsd");
wado->appendChild(httpTag);
}
httpTag->setAttribute("key", "callingAE");
httpTag->setAttribute("value", "DEVICE");
*/
return S_OK;
}
示例7: OnApplyMessage
LRESULT CSCProgramBlacklistDlg::OnApplyMessage(WPARAM wParam, LPARAM lParam)
{
MSXML2::IXMLDOMDocument *pXmlDoc = reinterpret_cast<MSXML2::IXMLDOMDocument *>(wParam);
ASSERT(pXmlDoc);
MSXML2::IXMLDOMElement *pRootElem = reinterpret_cast<MSXML2::IXMLDOMElement *>(lParam);
ASSERT(pRootElem);
MSXML2::IXMLDOMElementPtr ProccessList = pXmlDoc->createElement(_T("ProccessList"));
pRootElem->appendChild(ProccessList);
for (int i = 0; i < m_list.GetItemCount(); i++)
{
MSXML2::IXMLDOMElementPtr ProccessInfo = pXmlDoc->createElement(_T("ProccessInfo"));
ProccessList->appendChild(ProccessInfo);
ProccessInfo->setAttribute(_T("Name"), (LPCTSTR)m_list.GetItemText(i, 1));
ProccessInfo->setAttribute(_T("AddTime"), (LPCTSTR)m_list.GetItemText(i, 0));
ProccessInfo->setAttribute(_T("Description"), (LPCTSTR)m_list.GetItemText(i, 2));
}
return TRUE;
}
示例8: CreateSeriesNode
static HRESULT CreateSeriesNode(DcmDirectoryRecord *seriesRec, MSXML2::IXMLDOMElementPtr &study, MSXML2::IXMLDOMDocumentPtr &pXMLDom, const char *studyUID)
{
MSXML2::IXMLDOMElementPtr series = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "Series", "http://www.weasis.org/xsd");
if(series == NULL) return CO_E_NOT_SUPPORTED;
const char *buff = NULL, *seriesUID = NULL;
if(seriesRec->findAndGetString(DCM_SeriesInstanceUID, seriesUID).bad()) return CO_E_NOT_SUPPORTED;
else series->setAttribute("SeriesInstanceUID", seriesUID);
if(seriesRec->findAndGetString(DCM_Modality, buff).bad()) return CO_E_NOT_SUPPORTED;
else series->setAttribute("Modality", buff);
if(seriesRec->findAndGetString(DCM_SeriesDescription, buff).good()) series->setAttribute("SeriesDescription", buff);
if(seriesRec->findAndGetString(DCM_SeriesNumber, buff).good()) series->setAttribute("SeriesNumber", buff);
study->appendChild(series);
DcmDirectoryRecord *instanceRec = NULL;
while(instanceRec = seriesRec->nextSub(instanceRec))
{
if(instanceRec->getRecordType() != ERT_Image) continue;
CreateInstanceNode(instanceRec, series, pXMLDom, studyUID, seriesUID);
}
return S_OK;
}
示例9: Build
////////////////////////////////////////////////////////////////////////////
// Function: Create an XML DOM Document from Scratch in memory
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::Build()
{
// Create a root node
MSXML2::IXMLDOMNodePtr pRoot;
m_pDoc->createNode(CComVariant(MSXML2::NODE_ELEMENT), CComBSTR("Root"), NULL, &pRoot);
// add child nodes
HRESULT hr = S_OK;
for (int i = 0; i < 10; i++)
{
MSXML2::IXMLDOMNodePtr pNode;
m_pDoc->createNode(CComVariant(MSXML2::NODE_ELEMENT), CComBSTR("Order"), NULL, &pNode);
MSXML2::IXMLDOMElementPtr pElement = pNode;
if (pElement != NULL)
pElement->setAttribute(CComBSTR("id"), CComVariant(i));
MSXML2::IXMLDOMNodePtr p0 = NULL;
CComVariant after;
hr = pRoot->insertBefore(pNode, after, &p0);
hr = CheckHR(hr, "inserting node");
// The XML Document should now own the node.
for (int j = 0; j < 10; j++)
{
MSXML2::IXMLDOMNodePtr pNode2;
m_pDoc->createNode(CComVariant(MSXML2::NODE_ELEMENT), CComBSTR("Item"), NULL, &pNode2);
MSXML2::IXMLDOMElementPtr pElement2 = pNode2;
if (pElement2 != NULL)
pElement2->setAttribute(CComBSTR("id"), CComVariant((i*10) + j));
MSXML2::IXMLDOMNodePtr p1 = NULL;
CComVariant after;
hr = p0->insertBefore(pNode2, after, &p1);
hr = CheckHR(hr, "inserting node");
// The XML Document should now own the node.
}
}
// Now attach this new subtree to the document.
m_pDoc->appendChild(pRoot, NULL);
return hr;
}
示例10: SetAttrValue
//设置指定xpath的节点属性
BOOL CXmlBase::SetAttrValue(LPCTSTR lpszValue, LPCTSTR lpszAttrName, MSXML2::IXMLDOMNodePtr pNode)
{
if (lpszValue == NULL
|| lpszAttrName == NULL
|| pNode == NULL) return FALSE;
MSXML2::IXMLDOMElementPtr pElem = pNode;
//lc,国际化乱码问题
// CComVariant varText(_bstr_t(lpszValue).GetBSTR());
// HRESULT hr = pElem->setAttribute(_bstr_t(lpszAttrName).GetBSTR(), varText);
BSTR bstr = SysAllocString(_bstr_t(lpszValue).GetBSTR()); //modify memory leak
CComVariant varText(bstr);
BSTR bstrName =SysAllocString(_bstr_t(lpszAttrName).GetBSTR());
HRESULT hr = pElem->setAttribute(bstrName, varText);
SysFreeString(bstr);
bstr = NULL;
SysFreeString(bstrName);
bstrName = NULL;
if (FAILED(hr)) return FALSE;
return TRUE;
}
示例11: SetAttribute
// 设置属性值
int CBpXMLNode::SetAttribute(const wchar_t *szAttrName, const wchar_t *szAttrValue)
{
if (m_pDOMNode == NULL || szAttrName == NULL || szAttrValue == NULL)
return XML_ERROR;
if (m_pDOMNode->GetnodeType() != MSXML2::NODE_ELEMENT)
return XML_ERROR;
try
{
_bstr_t bstrName(szAttrName);
MSXML2::IXMLDOMElementPtr pElemt = (MSXML2::IXMLDOMElementPtr)m_pDOMNode;
pElemt->setAttribute(_bstr_t(szAttrName),_variant_t(szAttrValue));
}
catch (...)
{
return XML_ERROR;
}
return XML_OK;
}
示例12: TestDiscoverHyperLinks
void TestPPTAttachedDocument::TestDiscoverHyperLinks()
{
CStdString documentFileName = CreateTestResultDocument(GetDiscoverDocumentFileName(), _T(__FUNCTION__));
LPCTSTR expectedFileName = GetDiscoverExpectedXMLFileName();
LPCTSTR metadataNode = _T("HyperLinks");
LPCTSTR metadataElement = MWE_FIELDS;
DocumentManager spPresentation(documentFileName.c_str(), g_spPPTInstanceManager);
CStdString sTestDocumentFileName = documentFileName;
IMWMetadataElementsPtr spElements(__uuidof(CMetadataElements));
IMWDocumentsPtr spDocuments = m_spApplication->Documents;
IMWDocumentPtr spDocument = spDocuments->Open(spPresentation);
spElements->SelectNoElements();
spElements->Item[metadataElement]->Enabled = VARIANT_TRUE;
MSXML2::IXMLDOMDocumentPtr spActualMetadataDocument = spDocument->DiscoverMetadata(spElements);
CStdString sFileName = GetTestResultFileName(expectedFileName, _T(__FUNCTION__));
ResetAuthorPathToBlank(spActualMetadataDocument);
WriteXmlNodeToFile(sFileName, spActualMetadataDocument);
// Reload the actual xml into the dom to remove any empty nodes that may exist. This is only for the test
// and should not effect any other area of the system.
spActualMetadataDocument = LoadDocument(sFileName, GetXMLErrorFileName(_T(__FUNCTION__)));
MSXML2::IXMLDOMDocumentPtr spExpectedMetadataDocument = LoadDocument(expectedFileName, GetXMLErrorFileName(_T(__FUNCTION__)));
// Because we are working with a copy of the document, we must inject that name into the DOM otherwise
// our tests will fail.
IDispatchPtr spElement = spExpectedMetadataDocument->selectSingleNode(_T("/Metadata/Documents/Document"));
if(spElement == 0)
throw Workshare::Exception(_T("Failed to obtain the /Metadata/Documents/Document node from the document"));
MSXML2::IXMLDOMElementPtr spDocumentElement = spElement;
if(spDocumentElement == 0)
throw Workshare::Exception(_T("MSXML2::IXMLDOMElement is not implemented by the node returned from \"/Metadata/Documents/Document\""));
spDocumentElement->setAttribute(_T("Name"), documentFileName.c_str());
CStdString sBaseNodeName(_T("/Metadata/Documents/Document/"));
CStdString sXmlNode(sBaseNodeName);
sXmlNode += metadataNode;
MSXML2::IXMLDOMNodePtr spExpectedNode = spExpectedMetadataDocument->selectSingleNode(sXmlNode.c_str());
MSXML2::IXMLDOMNodePtr spActualNode = spActualMetadataDocument->selectSingleNode(sXmlNode.c_str());
assertMessage(spExpectedNode != 0, _T("The expected xml node should not be zero"));
assertMessage(spActualNode != 0, _T("The actual xml node should not be zero"));
assertXmlEqual(spExpectedNode, spActualNode);
for(long nIndex = 1; nIndex <= spElements->Count; nIndex++)
{
IMWMetadataElementPtr spElement = spElements->Item[nIndex];
// Only those elements selected should be discovered, so ignore the selected one
if(0 != lstrcmpi(spElement->Name, metadataElement))
{
sXmlNode = sBaseNodeName;
sXmlNode += static_cast<const TCHAR*>(spElement->Name);
MSXML2::IXMLDOMNodePtr spNode = spActualMetadataDocument->selectSingleNode(sXmlNode.c_str());
CStdString sMessage;
sMessage.Format(_T("\"%s\" was discovered and was not set."), static_cast<const TCHAR*>(spElement->Name));
assertMessage(spNode == 0, sMessage)
}
}
示例13: writeParam
BOOL WXmlParse::writeParam(const std::vector<WParamDefine *> ¶ms)
{
/*MSXML2::IXMLDOMDocumentPtr doc;
MSXML2::IXMLDOMElementPtr docRoot;
MSXML2::IXMLDOMElementPtr docElement;
MSXML2::IXMLDOMNodeListPtr elementNodes;
MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
MSXML2::IXMLDOMNodePtr xmlNode;
MSXML2::IXMLDOMNodePtr xmlSubNode;
MSXML2::IXMLDOMNodePtr xmlAttrNode;
doc.CreateInstance(__uuidof(DOMDocument30));
if (m_strFileName.IsEmpty())
{
return FALSE;
}
docRoot = doc->createElement("ModuleName");
//docRoot->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));
MSXML2::IXMLDOMElementPtr inputElement = doc->createElement("InputParam");
docRoot->appendChild(inputElement);
for (int i = 0;i < params.size();i++)
{
}*/
MSXML2::IXMLDOMDocumentPtr pDoc = NULL;
MSXML2::IXMLDOMElementPtr xmlRoot = NULL;
MSXML2::IXMLDOMElementPtr xmlInput = NULL;
MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL;
//创建DOMDocument对象
pDoc.CreateInstance(__uuidof(DOMDocument30));
pPI = pDoc->createProcessingInstruction("xml","version='1.0' encoding='gb2312'");
_variant_t vNullVal;
vNullVal.vt = VT_NULL;
pDoc->insertBefore(pPI, vNullVal);
//创建元素并添加到文档中
xmlRoot = pDoc->createElement((_bstr_t)"ModuleName");
//设置属性
pDoc->appendChild(xmlRoot);
appendTextNode(pDoc,xmlRoot,1);
xmlInput = pDoc->createElement((_bstr_t)"InputParams");
xmlInput->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));
xmlRoot->appendChild(xmlInput);
appendTextNode(pDoc, xmlInput, 2);
for (int i = 0;i < params.size();i++)
{
MSXML2::IXMLDOMElementPtr pProperty = pDoc->createElement((_bstr_t)"Property");
pProperty->setAttribute((_bstr_t)"name", (_bstr_t)(params[i]->m_name.c_str()));
xmlInput->appendChild(pProperty);
appendTextNode(pDoc, pProperty, 3);
WExtraMap::iterator it = params[i]->m_extraParams.begin();
while (it != params[i]->m_extraParams.end())
{
MSXML2::IXMLDOMElementPtr pText = pDoc->createElement((_bstr_t)it->first.c_str());
pText->put_text((_bstr_t)it->second.c_str());
pProperty->appendChild(pText);
appendTextNode(pDoc, pProperty, 3);
it++;
}
}
//添加“author”元素
// MSXML2::IXMLDOMElementPtr pNode;
// pNode=pDoc->createElement((_bstr_t)"Bank");
// xmlRoot->appendChild(pNode);
//
// appendTextNode(pDoc,pNode,2);
//
// MSXML2::IXMLDOMElementPtr pNode2;
// pNode2=pDoc->createElement((_bstr_t)"Head");
// pNode->appendChild(pNode2);
//
// appendTextNode(pDoc,pNode2,3);
//
// MSXML2::IXMLDOMElementPtr pNode3;
// pNode3=pDoc->createElement((_bstr_t)"PBCCode");
// pNode3->Puttext("局势");
// pNode2->appendChild(pNode3);
//
// appendTextNode(pDoc,pNode2,2);
//
// pNode3=pDoc->createElement((_bstr_t)"Code");
// pNode3->Puttext("局势");
// pNode2->appendChild(pNode3);
//
// ///////////////////////////////////////////////////
// appendTextNode(pDoc,pNode2,2);
// //////////////////////////////////////////////////////
// appendTextNode(pDoc,pNode,2);
//
// pNode2=pDoc->createElement((_bstr_t)"Table1");
// pNode->appendChild(pNode2);
//
// appendTextNode(pDoc,pNode2,3);
//
// pNode3=pDoc->createElement((_bstr_t)"PBCCode");
//.........这里部分代码省略.........
示例14: saveSourcesTab
//dedek:
BOOL CDataSourcesManager::saveSourcesTab()
{
BOOL ret = TRUE;
MSXML2::IXMLDOMDocumentPtr pXMLDom;
pXMLDom.CreateInstance(_T("Msxml2.DOMDocument"));
MSXML2::IXMLDOMElementPtr root_el; // korenovy element
root_el = pXMLDom->createElement("SOURCES_LIST");
pXMLDom->appendChild(root_el);
MSXML2::IXMLDOMElementPtr source_el; // source element
source_el = pXMLDom->createElement("SOURCE");
//atributy
MSXML2::IXMLDOMAttributePtr attr;
attr = pXMLDom->createAttribute("PUBLIC_ID");
source_el->setAttributeNode(attr);
attr.Release();
attr = pXMLDom->createAttribute("PERZISTENT_ID");
source_el->setAttributeNode(attr);
attr.Release();
attr = pXMLDom->createAttribute("PLUGIN_ID");
source_el->setAttributeNode(attr);
attr.Release();
for (int a=0; a<getSourcesCount(); a++)
{
MSXML2::IXMLDOMElementPtr e = source_el->cloneNode(VARIANT_TRUE);
e->setAttribute("PUBLIC_ID", (LPCTSTR) getSourcePublicID(a));
e->setAttribute("PERZISTENT_ID", (LPCTSTR) getSourcePersistentID(a));
e->setAttribute("PLUGIN_ID", (LPCTSTR) getSourcePlugin(a));
root_el->appendChild(e);
e.Release();
}
source_el.Release();
//default zdroj:
MSXML2::IXMLDOMElementPtr default_source;
default_source = pXMLDom->createElement("DEFAULT_SOURCE");
MSXML2::IXMLDOMAttributePtr src_attr;
src_attr = pXMLDom->createAttribute("PUBLIC_ID");
src_attr->value = (LPCTSTR) getDefaultSource();
default_source->setAttributeNode(src_attr);
src_attr.Release();
root_el->appendChild(default_source);
default_source.Release();
CDirectoriesManager & m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->DirectoriesManager;
// save list of data sources into config. file "ConfigDir/sources.xml"
try
{
ret = S_OK == pXMLDom->save((LPCTSTR) m.getSourcesConfigFilePath());
}
catch(...)
{
CReportAsistentApp::ReportError(IDS_DSLISTSAVE_ERR);
}
root_el.Release();
return ret;
}
示例15: Example
void Example()
{
cutting_tool_schema_arm::Ccutting_tool_schema_arm doc1 = cutting_tool_schema_arm::Ccutting_tool_schema_arm::LoadFromFile(ExeDirectory() + _T("ISO13399.XML"));
MSXML2::IXMLDOMNodePtr root = doc1.GetNode();
MSXML2::IXMLDOMNodeListPtr nodelist;
MSXML2::IXMLDOMNodePtr nextItem;
MSXML2::IXMLDOMNodeListPtr nodes=doc1.GetNode()->childNodes;
Traverse(nodes, 0);
// Example code to create and save a structure:
cutting_tool_schema_arm::Ccutting_tool_schema_arm doc = cutting_tool_schema_arm::Ccutting_tool_schema_arm::CreateDocument();
cutting_tool_schema_arm::CuosType uos = doc.uos.append();
/// ORGANIZATION
COrganization org = uos.Organization.append();
org.Delivery_address.append()="Someotherstreet 2, Sometown, Sweden";
org.Organization_name.append()="CTC -Cutting Tool Company";
org.Organization_type.append()="company";
org.Delivery_address.append() = "Someotherstreet 2, Sometown, Sweden";
org.Id2.append() = "SE556677889901";
org.Postal_address.append() = "Box 0000, Sometown, Sweden";
org.Visitor_address.append() = "Somestreet 1,Sometown, Sweden";
MSXML2::IXMLDOMElementPtr elem = org.GetNode();
elem->setAttribute("id", "id-1");
/// STATE
CState _state = uos.State.append();
_state.Name.append() = "Blunt edge";
elem = _state.GetNode();
elem->setAttribute("id", "id-3");
/*
<Item_characteristic_association id="id-4">
<Associated_characteristic>
<grade xsi:nil="true" ref="id-5"/>
</Associated_characteristic>
<Associated_item>
<item_definition xsi:nil="true" ref="id-6"/>
</Associated_item>
<Relation_type>has characteristic</Relation_type>
</Item_characteristic_association>
ENTITY item_characteristic_association;
associated_characteristic : item_characteristic_select;
associated_item : item_definition;
relation_type : OPTIONAL STRING;
END_ENTITY;
*/
// Item_characteristic_association
CItem_characteristic_association ica = uos.Item_characteristic_association.append();
elem = ica.GetNode();
elem->setAttribute("id", "id-4");
// associated_item : item_definition;
CAssociated_itemType assoc_item = ica.Associated_item.append();
elem= assoc_item.Item_definition.append().GetNode();
elem->setAttribute("ref", "id-6");
elem->setAttribute("xsi:nil", "true");
// associated_characteristic : item_characteristic_select;
CAssociated_characteristicType assoc_char = ica.Associated_characteristic.append();
elem= assoc_char.Grade.append().GetNode();
elem->setAttribute("ref", "id-5");
elem->setAttribute("xsi:nil", "true");
doc.SetSchemaLocation(_T("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"")); // optional
doc.SaveToFile(ExeDirectory() + "cutting_tool_schema_arm1.xml", true);
}