Discussion Locked

Standalone XML Parser

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

2 replies

by tony hopkinson

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.

by xmetal

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):

VALID: testfile1.xml

------------------------------------------------------------

INVALID: testfile2.xml
Line: 5
Position: 10
Source:
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.

This discussion is closed to new replies.