Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: XML validating (no DTD)

by iburrell (Chaplain)
on Sep 02, 2004 at 16:47 UTC ( #387992=note: print w/replies, xml ) Need Help??

in reply to XML validating (no DTD)

I don't see any DTD declared in the XML or the code. If you don't have a schema to validate against, you can't validate an XML document. Checking for well-formed is different, and something most parsers should report on. XML::Checker::Parser looks like it only validates against DTDs declared in the document.

You can also validate against XML Schema or RELAX NG. I don't know of any pure Perl code for those, but calling external programs and libraries work well.

Replies are listed 'Best First'.
Re^2: XML validating (no DTD)
by 2ge (Scribe) on Sep 02, 2004 at 21:33 UTC

    I just found the solution on perlmonks, it is so easy:
    use XML::Parser; my $p = XML::Parser->new; my $file = 'data.xml'; eval { $p->parsefile($file) }; if ($@) { print 'XML is not well formed'; } else { print 'XML is well formed'; }

    Ofcoure, I can't validate XML, if I don't have DTD, I can check it if it is well formed, sorry for mistake.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://387992]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2023-11-29 11:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found