Thread

Posted on Thu Dec 15 18:15:50 2005 by sabrina
From XML file format to Tabular file format
Dear all, I would like to parse a XML formatted file into a simple tabular formatted file. For this, I am using the XML::parser module for Perl and setHandlers(Start ; Char). I am getting the information for each tag from the XML file and then I am trying to print it into a file. The problem is that I do not know if it is possible to set other parameters to the setHandlers Char method (like the file descriptor) and how to do it. Does anybody know if it is possible to transform the Char method so as to be able to pass new parameters? If not, do you know another way of parsing a XML file into a tabular file format using Perl? Thank you very much in advance.
Direct Responses: 1487 | Write a response
Posted on Fri Dec 16 03:07:12 2005 by grantm in response to 1486
Re: From XML file format to Tabular file format

Before you get too much code written using the old XML::Parser API, I'd recommend you switch to SAX. The SAX API is very similar (so it's easy to switch) but it's object oriented, so you can store anything you like (eg: the filehandle) in your object and it will be available whenever one of your handler methods is called.

The Perl XML FAQ links to a number of articles by Kip Hampton including this one on XML::SAX::Machines.

If you install XML::SAX, be sure to install XML::SAX::Expat too - it's faster than the pure Perl parser in the SAX distribution.

PS: PerlMonks is a better place for this type of question.

Write a response