Create XML file from text file

M

matofarides

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
 
E

Ed Beroset

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
 
P

Peter Flynn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top