CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    154

    Exclamation XML DOM problem with node

    Hi,
    I have an XML document..

    <register name="RID" length="32" address="0x8" resetval="000" access="rw">
    <element name="RID" offset="1" length="7" access="rw">
    <desc>Revision Identification Number. </desc>
    <modified>true</modified>
    <state text="A0 stepping" value="" />
    <state text="A1 stepping" value="" />
    <state text="A2 stepping" value="" />
    <state text="B0 stepping" value="" />
    </element>
    </register>

    I need to access the "state" programically using MSXML..

    I could reach till element and their attributes..
    But I am unable to get to the "state" and text and value associated with it..
    Anybody had any idea..

    i have used the code below..

    Code:
    IXMLDOMNode   *pNode;
    IXMLDOMNode   *pNode_child;
    IXMLDOMNodeList  *childList;
    long atlen, pos,
    hr = pNode->get_childNodes(&childList); // gives the list of nodes under register
    hr = childList->get_length(&atlen_child);
    
    for(pos =0; pos<atlen_child;pos++)
    {
       hr = childList ->nextNode(&pNode_child);
       myFunc(pNode_child);
    }
    
    void myFunc(IXMLDOMNode *pNode_child)
    {
       IXMLDOMNamedNodeMap  *AtMap;
        pNode_child->get_attributes(&AtMap);
       AtMap->get_length(&atlen);
       for(pos = 0; pos<atlen;pos++)
      {
         // now we have the attributes of the element node.. 
        // now what shud be done for getting the 'state '
       }
    }
    Thank you

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: XML DOM problem with node

    You have not created the instance of 'pNode' and directly using it.

    - Ajay.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Oct 2004
    Posts
    154

    Re: XML DOM problem with node

    I dont understand..
    could you explain?

  4. #4
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: XML DOM problem with node

    Why not "pNode_child->getAttribute("text")" ?



    I dont understand..
    could you explain?
    Ajay Vijay coplain about missing things like that:
    ".CreateDispatch("MSXML2.DOMDocument")", "loadXML(" ... etc.

    U delcared "IXMLDOMNode *pNode;" but there is no assigment to that pointer.

    Best regards,
    Krzemo.
    Last edited by Krzemo; February 16th, 2005 at 06:45 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured