先說一下在MSDN哪里找文檔吧,往下看的時候也好有個參考:在Index里打:Windows Media Services 9 Series SDK=>PRogramming Reference=>Programming Reference (C++)=>XML DOM Interfaces (C++)。什么?Windows Media?呵呵,不錯,我覺得這個guide反而是最清楚的,你直接找MSXML,得到的結果,我覺得還沒這個好。
_bstr_t bstrXMLQuery = L"/books/book[@type=scifi and @author=fox]";
IXMLDOMNodeList* nodes = NULL; if(FAILED(XMLRoot->selectNodes(bstrXMLQuery, &nodes)) FAILED(nodes->get_length(&length)) length == 0) //no match found or something went wrong else //match found
最后提供一個sample,我臨時攢的。工作的時候寫的程序當然不能拿來貼的,呵呵。這個sample基本就是遍歷整個XML,然后報告一遍文件的結構,對每個node,假如它有一個叫id的attribute,就同時打印id的值。If you want the complete VS project, shoot me an email. But I guess no one really needs it anyway, right, : )