PHP SimpleXML

SimpleXML is arguably the simplest and fastest way to parse XML documents that is natively available in PHP.

<?php
$xml = '<articles>
<article id="1">
    <title>Something Happened</title>
    <author>Random Person</author>
</article>
<article id="2">
    <title>Something Else Happened</title>
    <author>Different Person</author>
</article>
</articles>';

/* load & parse XML string */
$art = simplexml_load_string($xml);
foreach ($art as $article) {
    echo 'Id: ' . $article['id'];
    echo 'Title: ' . $article->title;
    echo 'Author: ' . $article->author;
}
?>

Loading ...

Related Results :

  1. PHP SimpleXML
  2. Creating XML with DOM
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author