General discussion


Standalone XML Parser

By ianhenderson ·
Can any one help me? I want to have a standalone XML Parser, as in the past with SGML; most parsers did not give enough information.

Can any one tell me how I a make a XML Parser that parsers single documents and will give a report which show Line and Column numbers and what the errors is.

This can be either WEB based or Windows XP. But must be operated off line.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Lines & Columns ?

by Tony Hopkinson In reply to Standalone XML Parser

Lines is a null concept in xml, columns just don't exist at all.
If a document can't be parsed as xml then it isn't xml. You could show the tag where parsing failed and with what sort of error, but it may not acutally be where the error is of course. You can use msxml, saxon, in fact almost any parser locally. If you want to customise something for batch processing etc, then you ought to get one with source and then adapt it to your needs.

Collapse -


by xmetal In reply to Standalone XML Parser

I can give you tool that provides a GUI for validating XML files using MSXML. Same result as using script + MSXML to validate documents but lets you browse to and select your XML documents and then displays any errors in a dialog. You can then save the dialog text if you like. The errors are straight from MSXML. Here's an example report (validating two different files at one go):

VALI testfile1.xml


INVALI testfile2.xml
Line: 5
Position: 10
Source: <Sect1>
Reason: Element content is invalid according to the DTD/Schema.
Expecting: #PCDATA, Citation, Emphasis, Strong, TT, Underscore, InlineGraphic, Link, Subscript, Superscript, ULink.


Note that there is in fact a good reason to want to know which line and column contains the error - if you are using an editor that is not XML aware (plain text editor) then you need to locate the error somehow, right?

As it is now it requires MSXML 2.0, mscomctl.ocx and comdlg32.ocx be installed on your system (if you have XP or Win2K then you should be set). Send me an email and I'll send it along.

I assume that nobody would really want to use this as it is in real life. However, it does provide an example of how to batch process a bunch of XML files at once. I can provide source as a VB6 project in case you want to modify or use it as an example to do something else more useful.

Related Discussions

Related Forums