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. XML / XSL
  4. child nodes

child nodes

Scheduled Pinned Locked Moved XML / XSL
xml
5 Posts 2 Posters 16 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.
  • T Offline
    T Offline
    Todd Harvey
    wrote on last edited by
    #1

    I'm generating some C code from XML, and now I want to generate sub Structs. I know I can do the following (a child node of same name as parent node), value value But what I'm having problems with is getting the top-level structs with SelectNodes, and then getting sub-level structs with SelectNodes (or other select commands). I've been doing things like: //StructList = xDB->m_pDomDocument->getElementsByTagName("Struct"); StructList = xDB->m_pDomDocument->selectNodes("//Struct"); and have not gotten lucky yet. X|

    M 1 Reply Last reply
    0
    • T Todd Harvey

      I'm generating some C code from XML, and now I want to generate sub Structs. I know I can do the following (a child node of same name as parent node), value value But what I'm having problems with is getting the top-level structs with SelectNodes, and then getting sub-level structs with SelectNodes (or other select commands). I've been doing things like: //StructList = xDB->m_pDomDocument->getElementsByTagName("Struct"); StructList = xDB->m_pDomDocument->selectNodes("//Struct"); and have not gotten lucky yet. X|

      M Offline
      M Offline
      Michael A Barnhart
      wrote on last edited by
      #2

      I have not used any of the calls to return a selective list (just the entire list and then steped through it.) I believe it is quite picky on having a bstr as the argument not a char array as you have. Try declaring a "CComBSTR txt;" and then using it. What parser version are you using? Depending on what you are looking for it may be more direct to use an xslt transformation. To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli

      T 1 Reply Last reply
      0
      • M Michael A Barnhart

        I have not used any of the calls to return a selective list (just the entire list and then steped through it.) I believe it is quite picky on having a bstr as the argument not a char array as you have. Try declaring a "CComBSTR txt;" and then using it. What parser version are you using? Depending on what you are looking for it may be more direct to use an xslt transformation. To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli

        T Offline
        T Offline
        Todd Harvey
        wrote on last edited by
        #3

        thanks much I'm using MSXML v4 (current) the quoted text is working . . . although come to think of it, I always use BSTR's when convering from CStrings (doing this in MFC) xslt transformation - I have not yet had the courage to do that in C++ code About stepping throught the list . . . actually, what I am trying to do is very,very similar to the MSDN example where they recursed through a node set and displayed all the nodes in a CTreeCtrl . . . maybe I'll go back and try to figure out the recursion that needs to be done. If I can recurse through the node tree and keep track of which nodes are child to which, it might be less complicated than I am making it.

        M 1 Reply Last reply
        0
        • T Todd Harvey

          thanks much I'm using MSXML v4 (current) the quoted text is working . . . although come to think of it, I always use BSTR's when convering from CStrings (doing this in MFC) xslt transformation - I have not yet had the courage to do that in C++ code About stepping throught the list . . . actually, what I am trying to do is very,very similar to the MSDN example where they recursed through a node set and displayed all the nodes in a CTreeCtrl . . . maybe I'll go back and try to figure out the recursion that needs to be done. If I can recurse through the node tree and keep track of which nodes are child to which, it might be less complicated than I am making it.

          M Offline
          M Offline
          Michael A Barnhart
          wrote on last edited by
          #4

          have you looked at Ray Hayes demo? http://www.codeproject.com/soap/iexmlparser.asp This was with MSXML 3 but still applys to what you describe. To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli

          T 1 Reply Last reply
          0
          • M Michael A Barnhart

            have you looked at Ray Hayes demo? http://www.codeproject.com/soap/iexmlparser.asp This was with MSXML 3 but still applys to what you describe. To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli

            T Offline
            T Offline
            Todd Harvey
            wrote on last edited by
            #5

            thanks much, good demo, it does apply, and the comments below it were helpful too.

            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