本文整理汇总了C++中msxml2::IXMLDOMDocumentPtr::createProcessingInstruction方法的典型用法代码示例。如果您正苦于以下问题:C++ IXMLDOMDocumentPtr::createProcessingInstruction方法的具体用法?C++ IXMLDOMDocumentPtr::createProcessingInstruction怎么用?C++ IXMLDOMDocumentPtr::createProcessingInstruction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msxml2::IXMLDOMDocumentPtr
的用法示例。
在下文中一共展示了IXMLDOMDocumentPtr::createProcessingInstruction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveFileAs
/******************************************************************************
Function Name : SaveFileAs
Input(s) : CString omFilePath
Output : HRESULT
Functionality :
Member of : CTestSetupEntity
Friend of : -
Author(s) : Venkatanarayana Makam
Date Created : 06/04/2011
Modifications :
Codetag : CS006
******************************************************************************/
HRESULT CTestSetupEntity::SaveFileAs(CString omFilePath)
{
if(omFilePath.IsEmpty() == TRUE)
{
return S_FALSE;
}
MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
if ( FAILED(hr) )
{
return S_FALSE;
}
MSXML2::IXMLDOMProcessingInstructionPtr pIDomPi;
pIDomPi = pIDOMDoc->createProcessingInstruction(def_DOM_INSTRUCTION);
VARIANT_BOOL b = TRUE;
pIDOMDoc->put_preserveWhiteSpace(b);
if (pIDomPi != nullptr)
{
pIDOMDoc->appendChild(pIDomPi);
}
//testSETUP Node <testsetup>
MSXML2::IXMLDOMElementPtr pIDomTSNode = pIDOMDoc->createElement(_bstr_t(def_STR_TSNODE_NAME));
pIDOMDoc->appendChild(pIDomTSNode);
//Title Attribute <testsetup title = "">
MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TSATTRIB_TITLE);
if(pIDomTSAtrrib!= nullptr)
{
pIDomTSAtrrib->value = _bstr_t(m_omstrTestSetupTitle);
pIDomTSNode->setAttributeNode(pIDomTSAtrrib);
}
//Descriprion Node <testsetup title = ""><description>
MSXML2::IXMLDOMElementPtr pIDomDescriptionNode = pIDOMDoc->createElement(_bstr_t(def_STR_DESC_NODE));
pIDomDescriptionNode->Puttext(_bstr_t(m_omstrDescription));
pIDomTSNode->appendChild(pIDomDescriptionNode);
//Heade Node
MSXML2::IXMLDOMElementPtr pIDomHeaderNode = pIDOMDoc->createElement(_bstr_t(def_STR_HEADER_NAME));
nSaveHeader(pIDomHeaderNode, omFilePath);
pIDomTSNode->appendChild(pIDomHeaderNode);
//TestCase List
MSXML2::IXMLDOMElementPtr pIDomTestCaseNode = pIDOMDoc->createElement(_bstr_t(def_STR_TCLIST_NODE));
SetData(pIDomTestCaseNode);
pIDomTSNode->appendChild(pIDomTestCaseNode);
FormatDOMDocument(pIDOMDoc, omFilePath);
return S_OK;
}
示例2: 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;
}
示例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: CreateRootNode
CyNode CyDoc::CreateRootNode(const std::wstring& lpNodeName, bool bCreateHeadRow /*= false*/)
{
MSXML2::IXMLDOMDocumentPtr spDoc;
try
{
spDoc = GetDocument();
if(spDoc){
if ( bCreateHeadRow )
{
// Create a processing instruction targeted for xml.
MSXML2::IXMLDOMProcessingInstructionPtr pi;
pi = spDoc->createProcessingInstruction(L"xml", L"version=\"1.0\" encoding=\"UTF-8\"");
if (pi != NULL) {
spDoc->appendChild(pi);
}
}
// Create a comment for the document.
// MSXML2::IXMLDOMCommentPtr pc;
// pc = spDoc->createComment(_T("Generate by junyu application."));
// if (pc != NULL) {
// spDoc->appendChild(pc);
// }
// Create the root element (i.e., the documentElement).
MSXML2::IXMLDOMElementPtr pe;
pe = spDoc->createElement(lpNodeName.c_str());
if (pe != NULL) {
spDoc->appendChild(pe);
}
}
} catch(...) {
spDoc = NULL;
}
m_spDocument = spDoc;
return CyNode(spDoc);
}
示例5: 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");
//.........这里部分代码省略.........
示例6: SaveToXml
//保存项目
BOOL CUpdateBuilderDlg::SaveToXml(LPCTSTR pszFilePath)
{
ASSERT(pszFilePath!=NULL);
if (pszFilePath == NULL)
return FALSE;
HRESULT hr = S_OK;
MSXML2::IXMLDOMDocumentPtr pXmlDoc;
MSXML2::IXMLDOMElementPtr pRoot, pFileList, pFileNode;
_variant_t vFileName, vFileSize, vFileVersion, vMD5Key;
try
{
hr = pXmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
if( FAILED( hr ) )
_com_issue_error(hr);
pXmlDoc->PutpreserveWhiteSpace(VARIANT_TRUE);
pXmlDoc->Putasync(VARIANT_FALSE);
pXmlDoc->appendChild(pXmlDoc->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"));
pRoot = pXmlDoc->createElement("manifest");
pRoot->setAttribute("version", "1.0");
pRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema");
pXmlDoc->appendChild(pRoot);
pFileList = pXmlDoc->createElement("filelist");
pFileList->setAttribute("checksummode", "default");
for( int i = 0; i < m_FileListCtrl.GetItemCount(); i++ )
{
vFileName = m_FileListCtrl.GetItemText(i, 0);
vFILEVERSION 2,0,0,0
vMD5Key = m_FileListCtrl.GetItemText(i, 3);
vFileSize = (ULONG)m_FileListCtrl.GetItemData(i);
pFileNode = pXmlDoc->createElement("file");
pFileNode->setAttribute("filename", vFileName);
pFileNode->setAttribute("filesize", vFileSize);
pFileNode->setAttribute("fileversion", vFileVersion);
pFileNode->setAttribute("md5", vMD5Key);
pFileList->appendChild(pFileNode);
}
pRoot->appendChild(pFileList);
hr = pXmlDoc->save(pszFilePath);
if( FAILED( hr ) )
_com_issue_error(hr);
return TRUE;
}
catch(_com_error& e)
{
CString strError;
strError.Format(_T("Error code:%d\nError Message:%s\nError Description:%s"),
(int)e.WCode(), e.ErrorMessage(), (char*)e.Description());
MessageBox(strError, _T("错误"),MB_OK|MB_ICONSTOP);
}
return FALSE;
}