Deserialize xml do obiektu Symfony2

Zbieram dane w formacie XML za pośrednictwem interfejsu API i chciałbym je rozszeregować na liście obiektów. Używam Symfony2 i znajduję JMSSerializerBundle, ale tak naprawdę nie wiem, jak go używać.

Wiem, że Sf2 pozwala serializować / deserializować obiekt do / z tablicy, ale szukam czegoś bardziej szczegółowego. Na przykład dla tej klasy:

<code>class Screenshot
{
    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var string $url_screenshot
     */
    private $url_screenshot;


    public function __construct($id, $url_screenshot) {
        $this->id = $id;
        $this->url_screenshot = $url_screenshot;
    }


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set url_screenshot
     *
     * @param string $urlScreenshot
     */
    public function setUrlScreenshot($urlScreenshot)
    {
        $this->url_screenshot = $urlScreenshot;
    }

    /**
     * Get url_screenshot
     *
     * @return string 
     */
    public function getUrlScreenshot()
    {
        return $this->url_screenshot;
    }

    /**
     * Serializes the Screenshot object.
     *
     * @return string
     */
    public function serialize()
    {
        return serialize(array(
            $this->id,
            $this->url_screenshot
        ));
    }

    /**
     * Unserializes the Screenshot object.
     *
     * @param string $serialized
     */
    public function unserialize($serialized)
    {
        list(
            $this->id,
            $this->url_screenshot
        ) = unserialize($serialized);
    }

    public function __toString() {
        return "id: ".$this->id
              ."screenshot: ".$this->url_screenshot;
    }
}
</code>

Chciałbym serializować / deserializować do / z tego rodzaju XML:

<code><?xml version="1.0" encoding="UTF-8" ?>
<screenshots>
   <screenshot>
      <id>1</id>
      <url_screenshot>screenshot_url1</url_screenshot>
   </screenshot>
   <screenshot>
      <id>2</id>
      <url_screenshot>screenshot_url2</url_screenshot>
   </screenshot>
   <screenshot>
      <id>3</id>
      <url_screenshot>screenshot_url3</url_screenshot>
   </screenshot>
</screenshots>
</code>

Naprawdę chcę użyć czegoś zintegrowanego / zintegrowanego w Sf2 (coś „gładkiego”) i wolę unikać jakichkolwiek domowych parserów XML.

questionAnswers(1)

yourAnswerToTheQuestion