Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Search node in IXMLDOMDocument

Search node in IXMLDOMDocument

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JensB
    wrote on last edited by
    #1

    Hi, I need a 'find method' which returns a node in a IXMLDOMDocument. Is there any easy way to achieve this? Any tutorials/links about this? Thanks in advance, Jens

    A P 2 Replies Last reply
    0
    • J JensB

      Hi, I need a 'find method' which returns a node in a IXMLDOMDocument. Is there any easy way to achieve this? Any tutorials/links about this? Thanks in advance, Jens

      A Offline
      A Offline
      Antony M Kancidrowski
      wrote on last edited by
      #2

      You could try here Code Project[^] Or use the CP site search and look for "XML Document Wrapper" for instance. Ant. I'm hard, yet soft.
      I'm coloured, yet clear.
      I'm fruity and sweet.
      I'm jelly, what am I? Muse on it further, I shall return!
      - David Williams (Little Britain)

      J 1 Reply Last reply
      0
      • A Antony M Kancidrowski

        You could try here Code Project[^] Or use the CP site search and look for "XML Document Wrapper" for instance. Ant. I'm hard, yet soft.
        I'm coloured, yet clear.
        I'm fruity and sweet.
        I'm jelly, what am I? Muse on it further, I shall return!
        - David Williams (Little Britain)

        J Offline
        J Offline
        JensB
        wrote on last edited by
        #3

        Hi Antony, I have used that wrapper class you suggested already. It had a 'find' function in it, but it's pretty strangely coded that part. When he finds it, he adds it to the root node. Not exactly what i wanted to do with it. It should return a CXMLNode* or NULL if not found.

        A 1 Reply Last reply
        0
        • J JensB

          Hi Antony, I have used that wrapper class you suggested already. It had a 'find' function in it, but it's pretty strangely coded that part. When he finds it, he adds it to the root node. Not exactly what i wanted to do with it. It should return a CXMLNode* or NULL if not found.

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          It was quite a while ago that I looked at that class, I just remembered that there was a Find implementation. If it generally finds a node then you ought to be able to change the function to return CXMLNode*.

          CXMLNode* CXMLNode::Find(CXMLNode* rootNode, LPCTSTR nodeName, LPCTSTR nodeText, LPCTSTR attribName, LPCTSTR attribValue)

          Where it adds the node to the root replace

          CXMLNode *pNode = new CXMLNode(Nodes[i]);
          rootNode->Nodes.Add(pNode);

          with

          return Nodes[i];

          And right at the end of the function

          Nodes[i]->Find(rootNode,nodeName,nodeText,attribName,attribValue);
            
            }
            return NULL;
          }

          For your purposes you will probably not need to pass rootNode to the function and therefore all refrences to it can be removed. Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Williams (Little Britain)

          1 Reply Last reply
          0
          • J JensB

            Hi, I need a 'find method' which returns a node in a IXMLDOMDocument. Is there any easy way to achieve this? Any tutorials/links about this? Thanks in advance, Jens

            P Offline
            P Offline
            palbano
            wrote on last edited by
            #5

            JensB wrote: I need a 'find method' which returns a node in a IXMLDOMDocument Yes. SelectNodes() and SelectSingleNode() returns nodes matching an XPath statement. JensB wrote: Any tutorials/links about this? Tons. Try some of the sites listed at the bottom of this page. Also try GOOGLE: XML XPath tutorial reference

            "No matter where you go, there your are." - Buckaroo Banzai

            -pete

            J 1 Reply Last reply
            0
            • P palbano

              JensB wrote: I need a 'find method' which returns a node in a IXMLDOMDocument Yes. SelectNodes() and SelectSingleNode() returns nodes matching an XPath statement. JensB wrote: Any tutorials/links about this? Tons. Try some of the sites listed at the bottom of this page. Also try GOOGLE: XML XPath tutorial reference

              "No matter where you go, there your are." - Buckaroo Banzai

              -pete

              J Offline
              J Offline
              JensB
              wrote on last edited by
              #6

              Hi. Is it easy to integrate XPath functions into regular XML files? selectNodes() is not a member function of IXMLDocument for example

              P 1 Reply Last reply
              0
              • J JensB

                Hi. Is it easy to integrate XPath functions into regular XML files? selectNodes() is not a member function of IXMLDocument for example

                P Offline
                P Offline
                palbano
                wrote on last edited by
                #7

                JensB wrote: Is it easy to integrate XPath functions into regular XML files? I don't know what you mean. If you are using any parser that supports XPath queries ( MSXML does ) then it is integrated for you. You construct the XPath statement through whatever means is required to solve the current problem. You provide the statement as a text string to the parser engine (with MSXML it is the IXMLDOMDocument::SelectNodes() and SelectSingleNodes() methods) and it returns a node list of all nodes matching the XPath statement. JensB wrote: selectNodes() is not a member function of IXMLDocument for example It is a member of IXMLDOMDocument. It inherits that method as well as selectSingleNode() from the IXMLDOMNode interface. That allows you to execute relative XPath statements. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmthselectnodes.asp[^]

                "No matter where you go, there your are." - Buckaroo Banzai

                -pete

                A 1 Reply Last reply
                0
                • P palbano

                  JensB wrote: Is it easy to integrate XPath functions into regular XML files? I don't know what you mean. If you are using any parser that supports XPath queries ( MSXML does ) then it is integrated for you. You construct the XPath statement through whatever means is required to solve the current problem. You provide the statement as a text string to the parser engine (with MSXML it is the IXMLDOMDocument::SelectNodes() and SelectSingleNodes() methods) and it returns a node list of all nodes matching the XPath statement. JensB wrote: selectNodes() is not a member function of IXMLDocument for example It is a member of IXMLDOMDocument. It inherits that method as well as selectSingleNode() from the IXMLDOMNode interface. That allows you to execute relative XPath statements. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmmthselectnodes.asp[^]

                  "No matter where you go, there your are." - Buckaroo Banzai

                  -pete

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #8

                  Yes. This is verry handy and works great. I wasn't aware of the existence of 'XPath'. Thanks alot for the excellent help. Greetings, Jens

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups