Create XML file from text file

Discussion in 'XML' started by matofarides@gmail.com, Jan 5, 2006.

  1. Guest

    Hello all!

    I was wondering whether there was a way, using any XML parser
    (preferably xerces), to create an XML file by reading, line by line a
    text file.

    Thank you,


    Marios Tofarides
    , Jan 5, 2006
    #1
    1. Advertising

  2. Ed Beroset Guest

    wrote:
    > Hello all!
    >
    > I was wondering whether there was a way, using any XML parser
    > (preferably xerces), to create an XML file by reading, line by line a
    > text file.


    Generally not, since an XML parse, by definition, parses XML and plain
    text is not XML. What I've done in such situations is to write a parser
    for the source language (whatever kind of language is in the text file)
    using tools like lex and yacc (and the Java equivalents) and write
    simple production rules to generate meaningful XML. From there, you can
    use XSLT to further process the file contents, and *that* is where an
    XML parser can be useful.

    Ed
    Ed Beroset, Jan 5, 2006
    #2
    1. Advertising

  3. <> wrote in message
    news:...
    >
    > I was wondering whether there was a way, using any XML parser
    > (preferably xerces), to create an XML file by reading, line by line a
    > text file.
    >

    Wrong tool. You might want to have a look at
    http://servingxml.sourceforge.net/.

    Regards,
    Daniel Parker
    Daniel Parker, Jan 5, 2006
    #3
  4. Peter Flynn Guest

    wrote:
    > Hello all!
    >
    > I was wondering whether there was a way, using any XML parser
    > (preferably xerces), to create an XML file by reading, line by line a
    > text file.


    This is called an "up-translate" and can be done with pattern-matching
    software. It is possible using standard facilities like Regular
    Expressions implemented in (eg Perl, Python, Tcl, etc) or even using
    sed, awk, and grep, but it is much better to use a tool which knows
    about XML.

    Two possible tools are XSLT2 (eg as in Saxon8: saxon.sourceforge.net)
    or Omnimark (www.stilo.com), both of which can be used to pattern-match
    your way through plaintext data or text (and it doesn't even have to
    be line-by-line either).

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
    Peter Flynn, Jan 5, 2006
    #4
    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. Replies:
    2
    Views:
    585
    Daniel Parker
    Jan 5, 2006
  2. jkflens
    Replies:
    2
    Views:
    1,449
    jkflens
    May 30, 2006
  3. Dave
    Replies:
    1
    Views:
    978
    Juan T. Llibre
    Jun 8, 2007
  4. Krithika San
    Replies:
    3
    Views:
    326
    Marnen Laibow-Koser
    Nov 14, 2009
  5. Erik Wasser
    Replies:
    5
    Views:
    437
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page