Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: XML validating (no DTD)

by iburrell (Chaplain)
on Sep 02, 2004 at 16:47 UTC ( [id://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
    Hi

    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-23 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found