以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML工具及XML开发环境 』  (http://bbs.xml.org.cn/list.asp?boardid=7)
----  createElement问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=7&rootid=&id=6269)


--  作者:relaxxxxx
--  发布时间:3/29/2004 2:55:00 AM

--  createElement问题
VC.NET中.使用MSXML创建XML文件.
createProcessingInstruction和createComment函数调用都正确唯独createElement死活都出错.返回 E_FAIL. pElement地址无效. 可有人赐教.不胜感想
hr = CoInitialize(NULL);
   if(SUCCEEDED(hr))
{
    hr = CoCreateInstance(CLSID_DOMDocument,NULL,
   CLSCTX_INPROC_SERVER,
   IID_IXMLDOMDocument,(void**)&pDoc);
    if(SUCCEEDED(hr))
 {
                 
 hr = pDoc->createProcessingInstruction(strxml.AllocSysString( ),
strVersion.AllocSysString(),&pi);
    hr = pDoc->appendChild(pi,&pNode);
    if(SUCCEEDED(hr))
    {
     pNode->Release();
                                                                                pi->Release();
    }
    
    hr = pDoc->createComment(strElement.AllocSysString(),&pComment);
    hr = pDoc->appendChild(pComment,&pNode);
    if(SUCCEEDED(hr))
    {
    pNode->Release();
                                                                pComment->Release();
    };   
        hr =pDoc->createElement(strRootElement.AllocSysString(),&pElement);
     
    hr = pDoc->appendChild(pElement,&pNode);
    }
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms