比方说,我想创build一个XML-响应,将如下所示: <?xml version="1.0" encoding="utf‐8"?> <product xmlns="urn:com.acme.prods" xmlns:atom="http://www.w3.org/2005/xlink"> <id>1234</id> <name>Red Stapler</name> <price currency="EUR">3.14</price> <atom:link rel="payment" type="application/com.acme.shop+xml" href="http://acme.com/products/1234/payment" /> </product> 给定一个类似于下面的域模型: <?php // Product.php namespace Acme\Bundle\ProductBundle\Entity; use Acme\Bundle\ProductBundle\Money\Money; class Product { /** * @var integer */ private $id; /** * @var string */ private $name; /** * @var Money */ private $price; [..] } 和一个货币类别的线: <?php // […]