MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertBefore(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName) { MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument(); if (xmlDocument) { MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,""); newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)refNode); return newNode.Detach(); } return NULL; }
MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, LPCTSTR nodeName) { MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument(); if (xmlDocument) { MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,""); MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling(); if (nextNode.GetInterfacePtr() != NULL) newNode = m_xmlnode->insertBefore(newNode.Detach(),(IUnknown*)nextNode); else newNode = m_xmlnode->appendChild(newNode.Detach()); return newNode.Detach(); } return NULL; }
MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,MSXML2::IXMLDOMNodePtr pNode) { MSXML2::IXMLDOMNodePtr newNode = pNode->cloneNode(VARIANT_TRUE); if (newNode) { MSXML2::IXMLDOMNode* refNode = GetNode(index); if (refNode) newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode); else newNode = m_xmlnode->appendChild(newNode.Detach()); return newNode.Detach(); } else return NULL; }
MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertNode(int index,LPCTSTR nodeName) { MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument(); if (xmlDocument) { MSXML2::IXMLDOMNodePtr newNode = xmlDocument->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),nodeName,""); MSXML2::IXMLDOMNode* refNode = GetNode(index); if (refNode) newNode = m_xmlnode->insertBefore(newNode.Detach(),refNode); else newNode = m_xmlnode->appendChild(newNode.Detach()); return newNode.Detach(); } return NULL; }
MSXML2::IXMLDOMNode* CXmlNodeWrapper::InsertAfter(MSXML2::IXMLDOMNode *refNode, MSXML2::IXMLDOMNode *pNode) { MSXML2::IXMLDOMNodePtr nextNode = refNode->GetnextSibling(); MSXML2::IXMLDOMNodePtr newNode; if (nextNode.GetInterfacePtr() != NULL) newNode = m_xmlnode->insertBefore(pNode,(IUnknown*)nextNode); else newNode = m_xmlnode->appendChild(pNode); return newNode.Detach(); }