如何使用php创建blogger xml feed?

时间:2012-06-26 12:49:54

标签: php xml

如何使用php创建blogger xml feed?

<?xml version='1.0' encoding='UTF-8'?><ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom"><ns0:generator>Blogger</ns0:generator><ns0:entry><ns0:category scheme="http://www.blogger.com/atom/ns#" term="$category" /><br/><ns0:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/blogger/2008/kind#post" /><ns0:id>$postid</ns0:id><ns0:content type="html">$content</ns0:content><ns0:published>$published</ns0:published><ns0:title type="html">$title</ns0:title></ns0:entry></ns0:feed>

1 个答案:

答案 0 :(得分:0)

如果我理解你的问题,我的回复有望帮助你

$slideshow [] = array('item' => $new[$j], 'source' => $x,'zoom' => $y); 

   $doc = new DOMDocument();
   $doc->formatOutput = true;

  $r = $doc->createElement( "slideshow" );
  $doc->appendChild( $r );

  foreach( $slideshow as $item )
  {
  $b = $doc->createElement( "item" );

  $source = $doc->createElement( "source" );
  $source->appendChild(
  $doc->createTextNode( $item['source'] )
  );
  $b->appendChild( $source );

  $zoom = $doc->createElement( "zoom" );
  $zoom->appendChild(
  $doc->createTextNode( $item['zoom'] )
  );
  $b->appendChild( $zoom );

  $r->appendChild( $b );

  }
  echo $doc->saveXML();
  $doc->save("abc.xml")