3

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)

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383

3 Answers3

3

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?

Gordon
  • 312,688
  • 75
  • 539
  • 559
0

SimpleXml is by far the easiest! For any of the missing features in SimpleXml you can try bXml, a warper library I wrote.

null
  • 7,432
  • 4
  • 26
  • 28
0

If you want use PHP intern XML Parser there are

XPATH DOM SimpleXml

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; ?>
streetparade
  • 32,000
  • 37
  • 101
  • 123