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. Representing arrays of values in an XML file.

Representing arrays of values in an XML file.

Scheduled Pinned Locked Moved XML / XSL
c++data-structuresxmlhelpquestion
5 Posts 3 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
    Jack 2927
    wrote on last edited by
    #1

    I work primarily with C++ and trying to get a handle on XML. Consider the following class of data: classA { CString name; int widgits[3]; } Lets assume the data for the items in the class is: name = "Bob" widgits = {1,6,9} If I was to create an XML file to hold data such as that above, how would the array of widgits be represented? Would it look something like this? Bob 1 2 3 It doesnt seem that having 3 child elements named "widgit" under the parent named "data" would be correct. Afteral how would it get read back in correctly? Any help or keyword that I could use for a search would be appreciated. Even a good book on the subject ! Thank you for your help ! Jack

    G L 2 Replies Last reply
    0
    • J Jack 2927

      I work primarily with C++ and trying to get a handle on XML. Consider the following class of data: classA { CString name; int widgits[3]; } Lets assume the data for the items in the class is: name = "Bob" widgits = {1,6,9} If I was to create an XML file to hold data such as that above, how would the array of widgits be represented? Would it look something like this? Bob 1 2 3 It doesnt seem that having 3 child elements named "widgit" under the parent named "data" would be correct. Afteral how would it get read back in correctly? Any help or keyword that I could use for a search would be appreciated. Even a good book on the subject ! Thank you for your help ! Jack

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      It would be more like:

      <data>
      	<name>Bob</name>
      	<widgits>
      		<widgit>1</widgit>
      		<widgit>2</widgit>
      		<widgit>3</widgit>
      	</widgits>
      </data>
      

      since the widgets element would serve as a container (array) of widgets.

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      L 1 Reply Last reply
      0
      • J Jack 2927

        I work primarily with C++ and trying to get a handle on XML. Consider the following class of data: classA { CString name; int widgits[3]; } Lets assume the data for the items in the class is: name = "Bob" widgits = {1,6,9} If I was to create an XML file to hold data such as that above, how would the array of widgits be represented? Would it look something like this? Bob 1 2 3 It doesnt seem that having 3 child elements named "widgit" under the parent named "data" would be correct. Afteral how would it get read back in correctly? Any help or keyword that I could use for a search would be appreciated. Even a good book on the subject ! Thank you for your help ! Jack

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Jack 2927 wrote:

        It doesnt seem that having 3 child elements named "widgit" under the parent named "data" would be correct.

        Yes basically it is. Sometimes people or systems prefer a more verbose representation but the same basic principle applies: <data> <name>Bob</name> <widgetList>   <widgit>1</widgit>   <widgit>2</widgit>   <widgit>3</widgit> </widgetList> </data>

        led mike

        1 Reply Last reply
        0
        • G George L Jackson

          It would be more like:

          <data>
          	<name>Bob</name>
          	<widgits>
          		<widgit>1</widgit>
          		<widgit>2</widgit>
          		<widgit>3</widgit>
          	</widgits>
          </data>
          

          since the widgets element would serve as a container (array) of widgets.

          "We make a living by what we get, we make a life by what we give." --Winston Churchill

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Oh I got lagged. Serious lag, 11 minutes worth. :((

          led mike

          G 1 Reply Last reply
          0
          • L led mike

            Oh I got lagged. Serious lag, 11 minutes worth. :((

            led mike

            G Offline
            G Offline
            George L Jackson
            wrote on last edited by
            #5

            Well, at least we are on the same page for once!

            "We make a living by what we get, we make a life by what we give." --Winston Churchill

            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