MSXML中 如何使用getElementsByTagName ? ( 积分: 50 )

  • 主题发起人 主题发起人 warmfish
  • 开始时间 开始时间
W

warmfish

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
TOLEBOOL bSuccess=0;
HRESULT hr;
Msxml2_tlb::IXMLDOMDocument* pXMLDoc=NULL;
Msxml2_tlb::IXMLDOMNodeList *pNodeList=NULL;
hr=CoInitialize(NULL);
//COM的初始化
//得到关于IXMLDOMDocument接口的指针pXMLDOC。
hr=CoCreateInstance(Msxml2_tlb::CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
Msxml2_tlb::IID_IXMLDOMDocument,
(void**)&pXMLDoc);
WideString wsTemp=&quot;<?xml version=/&quot;1.0/&quot;?>/
<Tip> /
<Mode> /
<a>ff</a> /
</Mode> /
</Tip>&quot;;

bSuccess=pXMLDoc->loadXML(wsTemp);
if(bSuccess)
{
pNodeList=pXMLDoc->getElementsByTagName(WideString(&quot;Tip&quot;));
int iNumber=pNodeList->get_length();
....
}
问题: iNumber=0 ,为什么? 谢谢!
 
代码如下:
TOLEBOOL bSuccess=0;
HRESULT hr;
Msxml2_tlb::IXMLDOMDocument* pXMLDoc=NULL;
Msxml2_tlb::IXMLDOMNodeList *pNodeList=NULL;
hr=CoInitialize(NULL);
//COM的初始化
//得到关于IXMLDOMDocument接口的指针pXMLDOC。
hr=CoCreateInstance(Msxml2_tlb::CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
Msxml2_tlb::IID_IXMLDOMDocument,
(void**)&amp;pXMLDoc);
WideString wsTemp=&quot;<?xml version=/&quot;1.0/&quot;?>/
<Tip> /
<Mode> /
<a>ff</a> /
</Mode> /
</Tip>&quot;;

bSuccess=pXMLDoc->loadXML(wsTemp);
if(bSuccess)
{
pNodeList=pXMLDoc->getElementsByTagName(WideString(&quot;Tip&quot;));
int iNumber=pNodeList->get_length();
....
}
问题: iNumber=0 ,为什么? 谢谢!
 
后退
顶部