PHP code example of qingliangcn / wpxml-parser

1. Go to this page and download the library: Download qingliangcn/wpxml-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qingliangcn / wpxml-parser example snippets


$parser = new \qingliangcn\WPXmlParser\WPXmlParser();
$result = $parser->parse("wordpress.xml");

$parser = new \qingliangcn\WPXmlParser\WPXmlParser();

$result = $parser->parse("wordpress.xml");

$title = $parser->title;
$blogUrl = $parser->base_blog_url;
//文章列表
$posts = $parser->posts;
//分类列表
$categories = $parser->categories;
//tag列表
$tags = $parser->tags;
//多媒体(图片、附件等)列表
$attachments = $parser->attachments;

array(7) {
  ["generator"]=>
  string(30) "https://wordpress.org/?v=4.5.2"
  ["posts"]=>
  array(72) {
    [0]=>
    array(8) {
      ["title"]=>
      string(13) "Title"
      ["link"]=>
      string(38) "http://www.xxxx.org/2007/01/21/"
      ["pubData"]=>
      string(19) "2007-01-14 00:46:06"
      ["description"]=>
      string(0) ""
      ["excerpt"]=>
      string(0) ""
      ["content"]=>
      string(0) "post content is here"
      ["creator"]=>
      string(5) "admin"
      ["categoryStr"]=>
      string(15) "PostCategory"
      ["categories"]=>
      array(1) {
        [0]=>
        string(15) "PostCategory"
      }
    }
  ["wp_version"]=>
  string(5) "4.5.2"
  ["author"]=>
  array(6) {
    ["author_id"]=>
    int(1)
    ["author_login"]=>
    string(5) "admin"
    ["author_email"]=>
    string(16) "[email protected]"
    ["author_display_name"]=>
    string(6) "authorName"
    ["author_first_name"]=>
    string(0) "xxx"
    ["author_last_name"]=>
    string(0) "yyyy"
  }
  ["description"]=>
  string(0) ""
  ["base_site_url"]=>
  string(26) "http://www.xxxx.org"
  ["base_blog_url"]=>
  string(26) "http://www.xxxx.org"
}