-3

如何使用 php 创建博客 xml 提要?

<?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>

4

1 回答 1

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")
于 2012-06-26T13:05:08.923 回答