Creating an XML file

This is a discussion on Creating an XML file within the Tech Board forums, part of the Community Boards category; I've written a data converter in C++. The output today is fixed length records in ASCII TEXT format. I want ...

  1. #1
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309

    Creating an XML file

    I've written a data converter in C++. The output today is fixed length records in ASCII TEXT format. I want to add support for XML output.

    I've created XML documents in the past, but I've always taken a hacker's approach. By this I mean I simply remember the nesting level of the current set of tags I'm working with, and create subroutines where I'll pass a tag or data value and it will get wrapped in the appropriate delimiters ( "<>" & "</>"), be indented for ease of human reading, and be output. So, essentially, I've separated the data from the formatting, and only apply the formatting at output time.

    However, I suspect there might be libraries of functions that exist for outputting in XML format where I can define, perhaps, the namespace and then pass (essentially) raw data to it and it will do all the output formatting for me. Do such libraries exist?

    Thanks, Todd

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    XercesC is a pretty popular xml library, but it won't build the tree for you. It will validate your tree against a schema though.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    "schema" - that was the term I was looking for, not namespace. Thanks.

    Perhaps I should write one!!

    Thanks.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I would use Xerces as has been suggested. Tinyxml is also available but not nearly as robust.

    Be aware that Xerces is not all that friendly at first but once you get used to it, it's a snap. Xerces is also NOT thread safe.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    I suggest libxml. It works well, and is faster than any other implementation I've used.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21