Title: WordPress -&gt; XML -&gt; Flash
Last modified: August 19, 2016

---

# WordPress -> XML -> Flash

 *  [brasofilo](https://wordpress.org/support/users/brasofilo/)
 * (@brasofilo)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/wordpress-xml-flash/)
 * saw some old topics about, but apparently no solutions, so here are mines
 * i use this for feeding swf’s with xml generated by wordpress
    so, instead of 
   giving _myfile.xml_ as reference to flash, i give _myfile.xml.php_
 * example 1, **config.xml.php**, simple custom field query of post with id 101
 *     ```
       <?php
       require_once "../wp-load.php";
       $phone = get_post_meta(101, 'phone', true);
       $email = get_post_meta(101, 'email', true);
       $xml = <<<EOT
       <data>
       	<settings>
       		<phone>{$phone}</phone>
       		<email>{$email}</email>
       	</settings>
       </data>
       EOT;
       echo $xml;
       ?>
       ```
   
 * example 2, **gallery.xml.php?id=POST_ID**, full gallery of a post, got to feed
   the id in the url
 *     ```
       <?php
       	require_once "../wp-load.php";
       	$id = intval($_GET['id']);
   
       	function GetGallery($idi){
       		$idi = intval($idi);
       		$img = array();
       		$results = get_children( array(
       			'post_parent' => $idi,
       			'post_status' => 'inherit',
       			'post_type' => 'attachment',
       			'post_mime_type' => 'image',
       			'order' => 'ASC',
       			'orderby' => 'menu_order') );
       		foreach ( $results as $imagem )
       		{
       			$pic=wp_get_attachment_image_src( $imagem->ID, 'medium' );
       			$title = $imagem->post_title;
       			$txt = $imagem->post_content;
       			$img[] = array('href' => $pic[0], 'title' => $title, 'txt' => $txt);
       		}
       		return $img;
       	}
   
       	$GAL = GetGallery($id);
   
       	$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
       	$xml .= '<gallery>' . "\n\n";
   
       	$xml .= '<options>' . "\n\n";
       	$xml .= '    <name>ONE OF MANY</name>' . "\n\n";
       	$xml .= '</options>' . "\n\n";
   
       	$xml .= '<pictures>' . "\n\n";
       	foreach($GAL as $jpg) {
       		$xml .= '    <pic>' . "\n";
       		$xml .= '        <bigimage>' . $jpg['href'] . '</bigimage>' ."\n";
       		$xml .= '        <info title="'. $jpg['title'] .'" desc="'. $jpg['txt'] .'" />' . "\n";
       		$xml .= '    </pic>' . "\n\n";
       	}
       	$xml .= '</pictures>' . "\n\n";
       	$xml .= '</gallery>';
   
       	echo $xml;
       ?>
       ```
   
 * important:
    – path to _wp-load.php_, in these examples the files are inside _/
   wp-content_ – attention to the use of single and double quotes
 * i used 2 techniques to echo the xml, the first example uses one i discovered 
   recently
 * i think the second example opens the door to very complex xml structures
    you
   can try it saving the code as gallery.xml.php inside your wp-content, and then
   go to the address: [http://yousite.com/wp-content/gallery.xml.php?id=ID-OF-DESIRED-POST](http://yousite.com/wp-content/gallery.xml.php?id=ID-OF-DESIRED-POST)
 * good luck
    🙂

Viewing 1 replies (of 1 total)

 *  Thread Starter [brasofilo](https://wordpress.org/support/users/brasofilo/)
 * (@brasofilo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/wordpress-xml-flash/#post-1952342)
 * code above now in the pastebin
 * example 1: [http://pastebin.com/nSntsYJG](http://pastebin.com/nSntsYJG)
 * example 2: [http://pastebin.com/Sc1aeJ1b](http://pastebin.com/Sc1aeJ1b)

Viewing 1 replies (of 1 total)

The topic ‘WordPress -> XML -> Flash’ is closed to new replies.

## Tags

 * [as3](https://wordpress.org/support/topic-tag/as3/)
 * [flash](https://wordpress.org/support/topic-tag/flash/)
 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [slideshow](https://wordpress.org/support/topic-tag/slideshow/)
 * [template](https://wordpress.org/support/topic-tag/template/)
 * [xml](https://wordpress.org/support/topic-tag/xml/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [brasofilo](https://wordpress.org/support/users/brasofilo/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/wordpress-xml-flash/#post-1952342)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
