Reputation: 85318
What are the recommended libraries for XML in PHP? Advantages? Looking to create/send/parse XML. Needs to support High Volume (Millions of calls per day)
Upvotes: 3
Views: 2876
Reputation: 316989
PHP supports a number of XML libraries.
If memory is an issue, for instance due to large files, use an Event-based parser over a tree-based one.Tree-based parsers must fully load the file into memory in order to parse the XML. Event-based parsers do not need to load the entire file into memory to begin parsing.
See this article about what's new with XML in PHP5 and a discussion of their pros and cons.
You might also reconsider where you store the data, since filesystem might be too slow for millions of calls. How about Xindice?
Upvotes: 3
Reputation: 32888
If you want use PHP intern XML Parser there are
Or If you want to use a XML Parser for PHP i can recommend Simplepie
there are a lot but Simplepie is one of the Best.
Here is a Simple overview of how you could use it.
<?php
require_once('simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->init();
$feed->handle_content_type();
?>
<h1><a href="<?php echo $feed->get_permalink(); ?>">
<?php echo $feed->get_title(); ?></a></h1>
<p><?php echo $feed->get_description(); ?></p>
<?php foreach ($feed->get_items(0, 5) as $item): ?>
<h2 class="title"><a href="<?php echo $item->get_permalink(); ?>">
<?php echo $item->get_title(); ?></a></h2>
<?php echo $item->get_description(); ?>
<p>
<small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?>
</small></p>
<?php endforeach; ?>
Upvotes: 0