What is the best way to create C++ objects from parsed XML data?

Discussion in 'XML' started by Jim Williams, Aug 4, 2004.

  1. Jim Williams

    Jim Williams Guest

    **** Post for FREE via your newsreader at post.usenet.com ****

    I'm working on a 3d engine system.
    I need to save/load data in the systems objects to/from XML files.
    When I say objects, I mean C++ objects. (These generally correspond to
    scene objects, but that consideration isn't important as far as
    loading/saving goes.)

    I think I have a reasonable grasp of XML, it's method of data
    representation, and parsing XML files.
    (At the moment I'm looking at using the expat XML parser for it's
    callback based system, so I don't have to load/parse the whole -
    potentially v large - XML file into memory before I create objects).

    The problem I'm having is deciding how to get the data from the XML
    parser into the C++ objects.
    How is this normally done?
    Do you pass the completed/parsed XML node to the C++ object creator?
    Do you create the object object and set it's members with data from
    the completed/parsed XML node?

    What's the best/most flexible way to do this, or are what are pros and
    cons of various methods?
    Pointers to some examples would be greatly appreciated.

    Thanks

    Jim Williams

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
    http://www.usenet.com
    Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     
    Jim Williams, Aug 4, 2004
    #1
    1. Advertisements

  2. Jim Williams

    Fabien R Guest

    Jim Williams <> wrote in message news:<>...
    > **** Post for FREE via your newsreader at post.usenet.com ****
    >
    > I'm working on a 3d engine system.
    > I need to save/load data in the systems objects to/from XML files.
    > When I say objects, I mean C++ objects. (These generally correspond to
    > scene objects, but that consideration isn't important as far as
    > loading/saving goes.)
    >
    > I think I have a reasonable grasp of XML, it's method of data
    > representation, and parsing XML files.
    > (At the moment I'm looking at using the expat XML parser for it's
    > callback based system, so I don't have to load/parse the whole -
    > potentially v large - XML file into memory before I create objects).
    >
    > The problem I'm having is deciding how to get the data from the XML
    > parser into the C++ objects.
    > How is this normally done?
    > Do you pass the completed/parsed XML node to the C++ object creator?
    > Do you create the object object and set it's members with data from
    > the completed/parsed XML node?

    It depends on the message size. If it is too big, parse using the SAX
    method, otherwise, you may use DOM.
    >
    > What's the best/most flexible way to do this, or are what are pros and
    > cons of various methods?
    > Pointers to some examples would be greatly appreciated.

    http://xml.apache.org
    >
    > Thanks
    >
    > Jim Williams
    >

    You're welcome,
    Fabien
     
    Fabien R, Aug 5, 2004
    #2
    1. Advertisements

  3. "Jim Williams" <> wrote in message
    news:...
    > The problem I'm having is deciding how to get the data from the XML
    > parser into the C++ objects.
    > How is this normally done?


    > Do you pass the completed/parsed XML node to the C++ object creator?


    No. For one thing, I prefer to keep XML/DOM classes out of the declarations
    (member and argument types) of my own C++ classes.

    > Do you create the object object and set it's members with data from
    > the completed/parsed XML node?


    Yes that's the most common approach I've seen.

    /kmc
     
    Keith M. Corbett, Aug 8, 2004
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stan
    Replies:
    3
    Views:
    642
    Brock Allen
    May 5, 2005
  2. Katrin Tomanek

    Java and huge XML file to be parsed

    Katrin Tomanek, Jun 17, 2004, in forum: Java
    Replies:
    47
    Views:
    2,324
    Dale King
    Apr 15, 2006
  3. Kenneth McDonald
    Replies:
    1
    Views:
    486
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Oct 10, 2004
  4. Release
    Replies:
    1
    Views:
    415
    Gianni Mariani
    Oct 28, 2006
  5. Replies:
    0
    Views:
    492
  6. pamela
    Replies:
    0
    Views:
    165
    pamela
    Sep 12, 2005
  7. oldyork90
    Replies:
    1
    Views:
    319
    Jeremy J Starcher
    Sep 10, 2008
  8. Replies:
    8
    Views:
    510
    Jorgen Grahn
    May 16, 2013
Loading...