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

Re^2: How can i validate xml file?

by Anonymous Monk
on Feb 23, 2006 at 16:23 UTC ( #532307=note: print w/replies, xml ) Need Help??


in reply to Re: How can i validate xml file?
in thread How can i validate xml file?

Hi monkey_boy,

Thanks kool, It's working fine. But, I am getting xml content is it possible to check. And also, i am not allow here to use system function i want sample code.. For ex if i validate xml file with xsd file i use below code like i want code please

use XML::LibXML; my $schema_file = 'po.xsd'; my $document = 'po.xml'; my $schema = XML::LibXML::Schema->new(location => $schema_file); my $parser = XML::LibXML->new; my $doc = $parser->parse_file($document); eval { $schema->validate($doc) }; die $@ if $@; print "$document validated successfully\n";

Replies are listed 'Best First'.
Re^3: How can i validate xml file?
by davorg (Chancellor) on Feb 23, 2006 at 16:53 UTC

    If your input data is not well-formed XML (and I assume that's what you're asking about) then the parse_file call will die. Put a eval around that call and check the value in $@ after parse_file returns.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-12-05 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?