Well, my gut reaction would be to open the file and read in the first few lines and see if any of them match a regex. But that assumes that what you are looking for would always be near the start of the file.

On a more general note, anytime I hear a question that begins with "Is it possible to do ..." my immediate response is always "Yes! Just give me enough time and money." If I can't do it myself, I can hire the people who can. Do you want faster than light travel? Do you want anti-gravity? Just give me enough time and money.

Update: Here is a very crude approach that might work. (Please note that this is basic logic, NOT working code!)

open file for reading; $found_dtd = 0; while not end of file { next unless string has pattern known to be after DTD or schema if line matches DTD or schema regex { $found_dtd = 1; last; } } return $found_dtd;

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

In reply to Re: Quick check for XML DTD or Schema by boftx
in thread Quick check for XML DTD or Schema by ron800

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.