MSXML::IXMLDOMNode::GetchildNodes() always returns a Nodelist with length==0
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: MSXML::IXMLDOMNode::GetchildNodes() always returns a Nodelist with length==0

  1. #1
    Join Date
    Mar 2002
    Location
    Germany
    Posts
    63

    MSXML::IXMLDOMNode::GetchildNodes() always returns a Nodelist with length==0

    Hi.
    I created an xml file by hand which has a root node and several child nodes like this
    Code:
    <AnyRootNode anyAttribute="anyValue">
      <AnyChildNode anyChildAttribute="anotherValue"/>
      <AnyChildNode anyChildAttribute="anotherValue"/>
    </AnyRootNode>
    I use the following way trying to get the list of child nodes:

    Code:
    MSXML::IXMLDOMDocumentPtr docPtr;
    hResult =
      docPtr.CreateInstance (MSXML::CLSID_DOMDocument);
    if (FAILED (hResult)){
      return FALSE;
    }
    variant_t vResult =
      docPtr->load(XML_FILEPATH);
    
    if (((bool) vResult) == FALSE){
      return FALSE;
    }
    
    MSXML::IXMLDOMNodePtr pNode =
            docPtr->selectSingleNode("AnyRootNode");
    
    if (pNode==NULL){
      return FALSE;
    }
    
    MSXML::IXMLDOMNodeList* resultList =
      pNode->GetchildNodes();
    
    // **** HERE I ALWAYS GET A VALUE OF ZERO ****
    // WHY ???
    long listLength = resultList->Getlength();
    ...but what's wrong with that ?
    I expected to get a node list length of 2 for the example above.

  2. #2
    Join Date
    Mar 2002
    Location
    Germany
    Posts
    63

    Re: MSXML::IXMLDOMNode::GetchildNodes() always returns a Nodelist with length==0

    Ok, I found the answer myself:

    this one works...

    Code:
    MSXML::IXMLDOMNodeList* resultList;
    hResult =
      pNode->get_childNodes(&resultList);
    //...
    I'm confused...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center