Checking a file for well-formedness using the command line

U

Uwe Ziegenhagen

Hi,

we use ATOX to generate XML from ASCII text. However the created
documents are not always well-formed as some tags are misplaced. How can
I check from the command line under Linux, if the file is well-formed?

I would prefer a small executable, not a big framework...

Thanks in advance,

Uwe
 
J

Joseph Kesselman

Almost every XML parser comes with a tiny sample program which
demonstrates how to invoke it, and which will report well-formedness
errors and/or validity errors. You should be able to adapt that sample
to your needs. (Of course the parser itself may not be very small, but
the sample will be.)

Look at the user's clues for your favorite parser. If you don't have a
favorite, I'd suggest the Apache Xerces parsers since they're free and
high-quality and honor all the standards... but I'm a bit biased.
 
P

Pavel Lepin

Uwe Ziegenhagen said:
we use ATOX to generate XML from ASCII text. However the
created documents are not always well-formed as some tags
are misplaced.

No idea what ATOX is, but 'misplaced tags' indicates you're
going about it the wrong way. XML as you know it is just a
serialisation of a data structure. Tags don't really come
into it. Generate a tree of nodes, serialise it, and unless
you serialiser is borken, you won't have any 'misplaced
tags' problems.
How can I check from the command line under Linux, if the
file is well-formed?

I would prefer a small executable, not a big framework...

libxml2 package comes with most if not all major Linux
distributions. Chances are, you already have it installed.
xmllint is a command-line validating parser (with XInclude
processor and god knows what else slapped on top of it)
that comes with it.
 

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

No members online now.

Forum statistics

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

Latest Threads

Top