以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  紧急求助!好心人帮忙 谢谢! 关于用MSXML2::IXMLDOMDocumentPtr 分析xml 文件  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=36442)


--  作者:harvi125
--  发布时间:8/5/2006 2:42:00 PM

--  紧急求助!好心人帮忙 谢谢! 关于用MSXML2::IXMLDOMDocumentPtr 分析xml 文件

最近正在研究用MSXML2::IXMLDOMDocumentPtr来解析 xml 文件。

遇到的问题是节点名称前面带有了名空间"itunes",这样调用 m_pDoc->selectSingleNode() 就无法像分析普通xml文件那样获得节点。

谁能告诉我怎样利用 MSXML2::IXMLDOMDocumentPtr 来正确的到节点,并且获得图片的链接? 需要加入什么代码和条件?

xml 文件在最后。


这是我的一部分开始的代码:

MSXML2::IXMLDOMDocumentPtr   m_pDoc;
MSXML2::IXMLDOMElementPtr    m_channelImageNode;
CoInitialize(NULL);
HRESULT hr = m_pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));

 if(!SUCCEEDED(hr))
 {
  MessageBox(NULL,_T("error to create instance"),NULL,MB_OK);
 }

m_pDoc->load("c:\\test.xml");
m_channelImageNode = (MSXML2::IXMLDOMElementPtr)m_pDoc->selectSingleNode("//image");


test.xml :

  <?xml version="1.0" encoding="UTF-8" ?>
- <rss version="2.0" xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
- <channel>
  <title>読売ニュース ビデオポッドキャスト : YOMIURI ONLINE(読売新聞)</title>
  <link>http://podcast.yomiuri.co.jp/video_news/</link>
  <description>ttdescription>
  <language>ja-JP</language>     
<itunes:image href="http://ranksp.podcastjuice.jp/img/spiTMSAW/yomiurivideo.jpg" >
  <itunes:author>読売新聞社</itunes:author>
- <itunes:category text="News">
  <itunes:category text="All" />
  </itunes:category>
  <lastBuildDate>Fri, 4 Aug 2006 18:17:47 +0900</lastBuildDate>
  <dc:creator />
  </channel>
</rss>


--  作者:fooksuen
--  发布时间:4/13/2007 3:53:00 PM

--  xpath problem
not //image but
//itunes:image
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms