PHP code example of wp-php-toolkit / xml

1. Go to this page and download the library: Download wp-php-toolkit/xml 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/ */

    

wp-php-toolkit / xml example snippets



WordPress\XML\XMLProcessor;

$xml = <<<'XML'
<catalog>
<book sku="A1" price="29.99"><title>PHP Internals</title></book>
<book sku="A2" price="14.50"><title>WordPress at Scale</title></book>
</catalog>
XML;

$p = XMLProcessor::create_from_string( $xml );
while ( $p->next_tag( 'book' ) ) {
	$old = (float) $p->get_attribute( '', 'price' );
	$new = number_format( $old * 1.10, 2, '.', '' );
	$p->set_attribute( '', 'price', $new );
}

echo $p->get_updated_xml();


WordPress\XML\XMLProcessor;

$wxr = <<<'XML'
<?xml version="1.0"


WordPress\XML\XMLProcessor;

$wxr = <<<'XML'
<?xml version="1.0"


WordPress\XML\XMLProcessor;

$opml = <<<'XML'
<?xml version="1.0"