How do programmers normally write XML files?

Discussion in 'XML' started by Ramon F Herrera, Mar 23, 2008.

  1. (newbie alert)

    I am developing a C++ application, and decided that the best format to
    save files is in this newfangled :) XML thing.

    I already had a similar problem in Java and found a healthy number of
    implementations. I also found several which are written in C++, like
    this one, which seems very attractive:

    http://xerces.apache.org/xerces-c/

    The question I have is about writing XML files. I am under the
    impression that most of the hard work is the reading and the parsing.
    I can't find a simple example in which there is writing. Is writing so
    easy (compared with parsing, that is) that people just roll their own
    and don't use XML libraries?

    What I am really looking for is a library/sample code (Xerces is my
    top choice right now) that writes a simple, tutorial type XML file. I
    just want to make sure that the library is a fit for my problem.

    TIA!

    -RFH
     
    Ramon F Herrera, Mar 23, 2008
    #1
    1. Advertising

  2. Ramon F Herrera

    Peter Flynn Guest

    Ramon F Herrera wrote:
    > (newbie alert)
    >
    > I am developing a C++ application, and decided that the best format to
    > save files is in this newfangled :) XML thing.


    Hardly newfangled nowadays...it's been over a decade, and its
    predecessor for another decade before that.

    > I already had a similar problem in Java and found a healthy number of
    > implementations. I also found several which are written in C++, like
    > this one, which seems very attractive:
    >
    > http://xerces.apache.org/xerces-c/
    >
    > The question I have is about writing XML files.


    It depends what you mean by *writing*.

    A) If you are using XML for marking up data for storage or transfer
    between applications, that's usually done under program control,
    by library calls, so *you* don't actually write anything with your
    fingers.

    B) On the other hand if you're talking about authoring text, like
    documentation, articles, books, etc, then you need a decent XML
    editor if you want to do it in XML. There are almost no usable ones
    except for technical authoring.

    > I am under the
    > impression that most of the hard work is the reading and the parsing.


    By the look of it you're talking about (A). Xerces is a parser, just one
    (critical) component of an XML toolchain. There are many others. In
    isolation, a parser won't do very much for you except parse your
    incoming and outgoing XML (checking it for syntax: well-formedness).

    You will also need an XML editor, at least to open the [test] file
    you write so that you can see that they've been done right.

    > I can't find a simple example in which there is writing. Is writing so
    > easy (compared with parsing, that is) that people just roll their own
    > and don't use XML libraries?


    All the people I know who do this stuff use XML libraries. They exist
    for every language AFAIK (even COBOL :)

    > What I am really looking for is a library/sample code (Xerces is my
    > top choice right now) that writes a simple, tutorial type XML file. I
    > just want to make sure that the library is a fit for my problem.


    If we knew what your problem was, we might be able to recommend something.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Mar 23, 2008
    #2
    1. Advertising

  3. On Mar 23, 7:50 am, Peter Flynn <> wrote:
    > Ramon F Herrera wrote:
    > > (newbie alert)

    >
    > > I am developing a C++ application, and decided that the best format to
    > > save files is in this newfangled :) XML thing.

    >
    > Hardly newfangled nowadays...it's been over a decade, and its
    > predecessor for another decade before that.
    >
    > > I already had a similar problem in Java and found a healthy number of
    > > implementations. I also found several which are written in C++, like
    > > this one, which seems very attractive:

    >
    > > http://xerces.apache.org/xerces-c/

    >
    > > The question I have is about writing XML files.

    >
    > It depends what you mean by *writing*.
    >
    > A) If you are using XML for marking up data for storage or transfer
    > between applications, that's usually done under program control,
    > by library calls, so *you* don't actually write anything with your
    > fingers.
    >
    > B) On the other hand if you're talking about authoring text, like
    > documentation, articles, books, etc, then you need a decent XML
    > editor if you want to do it in XML. There are almost no usable ones
    > except for technical authoring.
    >
    > > I am under the
    > > impression that most of the hard work is the reading and the parsing.

    >
    > By the look of it you're talking about (A). Xerces is a parser, just one
    > (critical) component of an XML toolchain. There are many others. In
    > isolation, a parser won't do very much for you except parse your
    > incoming and outgoing XML (checking it for syntax: well-formedness).
    >
    > You will also need an XML editor, at least to open the [test] file
    > you write so that you can see that they've been done right.
    >
    > > I can't find a simple example in which there is writing. Is writing so
    > > easy (compared with parsing, that is) that people just roll their own
    > > and don't use XML libraries?

    >
    > All the people I know who do this stuff use XML libraries. They exist
    > for every language AFAIK (even COBOL :)
    >
    > > What I am really looking for is a library/sample code (Xerces is my
    > > top choice right now) that writes a simple, tutorial type XML file. I
    > > just want to make sure that the library is a fit for my problem.

    >
    > If we knew what your problem was, we might be able to recommend something.
    >
    > ///Peter
    > --
    > XML FAQ:http://xml.silmaril.ie/


    Thanks for your answer, Peter. I should have clarified that my
    concerns are those of a programmer. I am designing my own file format,
    which is pretty straightforward: a handful different objects, each one
    with a set of attributes which vary a little from one class of object
    to the next.

    I downloaded Xerces-C and have playing with the samples; I debating
    with myself if it is worth all the trouble, just to write a simple
    file and place the tags in the proper places.

    OTOH, and needless to say, I will *definitely* need the parsing
    functions of the library in order to read files, later on.

    -RFH
     
    Ramon F Herrera, Mar 23, 2008
    #3
    1. Advertising

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. Keith
    Replies:
    4
    Views:
    514
    Keith
    Jan 22, 2004
  2. Prime
    Replies:
    2
    Views:
    1,652
    Prime
    Oct 1, 2004
  3. =?Utf-8?B?YXJp?=

    how is this normally done?

    =?Utf-8?B?YXJp?=, Sep 30, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    369
    =?Utf-8?B?YXJp?=
    Oct 3, 2005
  4. dannyDog
    Replies:
    56
    Views:
    47,724
    George Cherry
    Jun 15, 2005
  5. Earl Eiland
    Replies:
    0
    Views:
    404
    Earl Eiland
    Feb 9, 2005
Loading...

Share This Page