XML::Liberal

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite & 1 Group

    XML::Liberal - Presentation Transcript

    1. XML::Liberal Tatsuhiko Miyagawa [email_address] Six Apart, Ltd. / Shibuya Perl Mongers YAPC::NA 2006 Chicago
      • Quiz:
      • What's wrong
      • with following XMLs?
    2. <?xml version=&quot;1.0&quot;?> <heroes>Larry & Damian</heroes>
    3. <?xml version=&quot;1.0&quot;?> <heroes>Larry &amp; Damian</heroes>
    4. <?xml version=&quot;1.0&quot;?> <shout> I &hearts; Perl &amp; Ruby! </shout>
    5. <?xml version=&quot;1.0&quot;?> <shout> I &#x2665; Perl &amp; Ruby! </shout>
    6. <?xml version=&quot;1.0&quot;?> <html> <body> <a href=foo.html>Foo foo!</a> </body> </html>
    7. <?xml version=&quot;1.0&quot;?> <html> <body> <a href= &quot;foo.html&quot; >Foo foo!</a> </body> </html>
    8. <?xml version=&quot;1.0&quot;?> <html> <body> <a href=&quot;/search?q=YAPC+NA&hl=en&quot;>Search for YAPC</a> </body> </html>
    9. <?xml version=&quot;1.0&quot;?> <html> <body> <a href=&quot;/search?q=YAPC+NA &amp; hl=en&quot;>Search for YAPC</a> </body> </html>
    10. <?xml version=&quot;1.0&quot;?> <rss version=&quot;2.0&quot;> <channel> <item> <title>YAPC is love</title> <content:encoded>Here I am!</content:encoded> </item> </channel> </rss>
    11. <?xml version=&quot;1.0&quot;?> <rss version=&quot;2.0 xmlns:content=&quot;http://purl.org/rss/1.0/modules/content/&quot; > <channel> <item> <title>YAPC is love</title> <content:encoded>Here I am!</content:encoded> </item> </channel> </rss>
    12. <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <search> <result> <excerpt>YAPC 最高 ! ...</excerpt> </result> </search>
    13. <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <search> <result> <excerpt>YAPC 最高 ! □ ...</excerpt> </result> </search>
      • If you're
      • a feed publisher,
      • Make sure
      • your feed is valid.
      • If you're a feed consumer,
      • Not being able
      • to parse broken feeds
      • might make your users unhappy.
      • As we saw
      • in the Quiz
      • Detecting XML errors
      • Is easy and simple
      • (sometimes).
      • Browsers deal
      • With it.
      • Human can
      • parse it.
      • Why not XML parsers
      • doing the same thing?
      • XML::Liberal
      • Does it for you.
      • Demo
      • Usage #1
      • If you use XML::LibXML
    14. use strict; use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parser->parse_string($xml);
    15. use strict; use XML::Liberal; my $parser = XML::Liberal->new(&quot;LibXML&quot;); my $doc = $parser->parse_string($xml);
      • Note: There's NO
      • performance drawback
      • If the data is valid
      • $parser->max_fallback(3)
      • Usage #2
      • If you use XML::LibXML
      • Without control to
      • change the code
    16. use strict; use XML::Liberal; XML::Liberal->globally_override('LibXML'); # later on … my $parser = XML::LibXML->new;
      • Usage #3
      • If you don't use LibXML
    17. use strict; use XML::FooParser; $doc = parse_xml($xml);
    18. use strict; use XML::FooParser; use XML::Liberal; eval { $doc = parse_xml($xml) }; if ($@){ my $p = XML::Liberal->new('LibXML'); my $d = $p->parse_string($xml); $xml = $d->toString(1); $doc = parse_xml($xml); }
      • XML::Liberal
      • Came out of Plagger
      • http://plagger.org/
      • cpan XML::Liberal
      • Thank you

    + miyagawamiyagawa, 3 years ago

    custom

    1918 views, 1 favs, 0 embeds more stats

    in YAPC::NA 2006

    More Info

    © All Rights Reserved

    Go to text version
    • Total Views 1918
      • 1918 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 65
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories

    Groups / Events