Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

DTD for XML - What is the best parser?

by gmpassos (Priest)
on May 26, 2004 at 01:16 UTC ( #356424=perlquestion: print w/ replies, xml ) Need Help??
gmpassos has asked for the wisdom of the Perl Monks concerning the following question:

Felow Monks,

All of use have listen a lot about XML, and all the tools that exits in CPAN for that. Now I'm looking for a good DTD parser to use. I have never listen anything about DTD for XML in Perl yet, so, I'm asking for your opinions on that.

Looking on CPAN I have found this 2 modules:

  • XML::DTDParser
  • XML::ParseDTD
  • But I haven't tested them yet. I'm looking for something stable, and in the parsed tree, that need to give me all the informations that a DTD can have. Any other extra resource for now is not important.

    Graciliano M. P.
    "Creativity is the expression of the liberty".

    Comment on DTD for XML - What is the best parser?
    Re: DTD for XML - What is the best parser?
    by castaway (Parson) on May 26, 2004 at 05:13 UTC
      You missed XML::LibXML::Dtd, LibXML requires you to install the c library libxml2, but its the most complete XML creator/parser out there, as far as I can see. That's what I picked when I was looking for a DTD Parser. I can't remember now what the two you mention were like, but I know I found LibXML more useful.

      (And started to create a DTD verifier/generator, since apparently there is/was a complete lack of those too.)

      C.

    Re: DTD for XML - What is the best parser?
    by mirod (Canon) on May 26, 2004 at 09:25 UTC

      What do you want to do with the DTD?

      • if you want to check documents against it, then you can use XML::Checker or XML::LibXML (set validation on by using $parser->validation(1);),
      • if you need info about the DTD then good ole XML::Parser allows you to set handlers on the various events in the DTD,
      • then if what you need is to get the default attributes or to expand entities in the XML, I usually do this as a separate process, using a standalone tool. xmllint which comes with libxml2 should do this, I use osx as my data is originally in SGML.
    Re: DTD for XML - What is the best parser?
    by DaveH (Monk) on May 26, 2004 at 15:18 UTC

      Hi.

      I have recently used XML::DTDParser for a project and I found that it was exactly what I was looking for. It provides a convenient Perl datastructure representing a DTD which does exactly what you want: parses a DTD. There is no extra "fluff" or additional functionality which gets in the way of achieving what you want.

      This said, I was not concerned with performance, nor was I writing code which I expected to be extensively reused in other projects (or reviewed by other developers). I was just writing a quick and dirty script to solve a problem, which is I believe exactly what XML::DTDParser's author (Jenda) had in mind when writing this module.

      If you want something simple, I would recommend XML::DTDParser. If you are after a more complete XML library, I would look into XML::LibXML.

      I hope this helps.

      Cheers,

      -- Dave :-)


      $q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://356424]
    Approved by DaWolf
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2014-12-29 09:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (185 votes), past polls