locked
IXMLDOMNodeList::getlength @ MSXML RRS feed

  • Question

  • hello,
       when I trying to use IXMLDOMNodeList::get_length(),  it gives me E_PENDING of HRESULT value. What is wrong? The program is as follows:
    The program can be compiled and run.

    labReport::labReport(std::string fileName){
     long length=10;
     IXMLDOMNode *pIDOMNode = NULL, *pIDOMNode2=NULL;
     IXMLDOMNamedNodeMap  *pAttribs=NULL;
     _variant_t value;
     CoInitialize(NULL);
     try {    
     CComPtr<IXMLDOMDocument> spXMLDOM;  
     HRESULT hr = spXMLDOM.CoCreateInstance(__uuidof(DOMDocument));  
     if ( FAILED(hr) ) throw "Cannot create XML Parser object";  
     if ( spXMLDOM.p == NULL ) throw "Cannot create XML Parser object";  
     VARIANT_BOOL bSuccess = false;  
     hr = spXMLDOM->load(CComVariant(L"L1-2S04.xml"),&bSuccess);  
     if ( FAILED(hr) ) throw "Cannot load XML file into the Parser";  
     if ( !bSuccess ) throw "Cannot load XML file into the Parser";  
     // Search 
     IXMLDOMNodeList *pIDOMNodeList = NULL;
     hr = spXMLDOM->getElementsByTagName(L"Line", &pIDOMNodeList); 
        hr = pIDOMNodeList->get_length(&length);  //hr==E_PENDING??
     for(int i = 0; i< length; i++){
      pIDOMNodeList->get_item(i,&pIDOMNode);
      if(pIDOMNode){
       pIDOMNode->get_attributes(&pAttribs);
       pAttribs->get_item(0,&pIDOMNode2);
       pIDOMNode2->get_nodeValue(&value);
       //std::cout<<std::string(_bstr_t(value))<<std::endl;
      }
     }

     } // catch  
     catch(...) {    
     std::cout << "Unkown Error!..." << std::endl << std::endl;  
     } // catch   
     CoUninitialize();  
    }

    Sunday, August 24, 2008 9:52 PM

Answers


  • Does it help if you set the async property (using put_async) of document object to VARIANT_FALSE before loading the file?


    • Marked as answer by Shiyuan Tuesday, August 26, 2008 10:01 PM
    Monday, August 25, 2008 8:15 AM