[Israel.pm] Is there a Perl equivalent to the PHP function "simplexml_load_file"?

Shlomi Fish shlomif at iglu.org.il
Thu Nov 6 07:57:33 PST 2008


On Thursday 06 November 2008, Oren Maurer wrote:
> I have seen a PHP code like this
>
> ==============================
>         $xml = simplexml_load_file($request);
>
>          // items
>         $Base = $xml->Items->Item;
> ==============================
>
> I want to try it in Perl.
> Is there an equivalent to the simplexml_load_file() function?
>

There's XML-Simple, which is similar:

http://search.cpan.org/dist/XML-Simple/

It converts XML into a Perl-5-data-structure and back. I avoid it like the 
plague, because I feel that XML does not map directly to Perl 5 data 
structures, and because XML::Simple has poor support for handling markup like 
qq{<p> Hello <a href="http://world.tld/">World</a>! </p>}. Instead, I tend to 
use XML::LibXML with DOM and XPath.

There's also XML::All: http://search.cpan.org/dist/XML-All/ .

I don't know exactly how PHP is doing it, but in Perl, I find DOM/XPath more 
robust and less philosophically problematic than an OXM (Object-XML-Mapping) 
solution.

Regards,

	Shlomi Fish

-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://xrl.us/bjn84

Shlomi, so what are you working on? Working on a new wiki about unit testing 
fortunes in freecell? -- Ran Eilam



More information about the Perl mailing list