0

I'm trying to deserialise the following XML:

<?xml version="1.0" encoding="utf-8"?>
<customers>
   <customer>
      <name>..</name>
      <address>..</address>
      <email>..</email>
      <website>..</website>
   </customer>
   <customer>
      ...
   </customer>
<customers>

I have made the following entity:

use JMS\Serializer\Annotation as JMS;    

class customers
{

    public function __construct()
    {
        $this->customers = new ArrayCollection();
    }

    /**
    * @JMS\Type("ArrayCollection<MyBundle\Entity\customer>")
    * @JMS\XmlList(entry="customer")
    */
    public $customers;
}

This is the second entity:

use JMS\Serializer\Annotation as JMS;    

class customer
{

    /**
    * @JMS\Type("string")
    */
    public $name;

    /**
    * @JMS\Type("string")
    */
    public $address;

    /**
    * @JMS\Type("string")
    */
    public $email;

    /**
    * @JMS\Type("string")
    */
    public $website;
}

Then I use the following code in the controller to serialise:

$serializer = $this->get('jms_serializer');
$customers = $serializer->deserialize($inputStr, 'MyBundle\Entity\customers', 'xml');

Only the object keeps up getting empty?

Tom
  • 1,547
  • 7
  • 27
  • 50

1 Answers1

0

Try changing, in class Customers, the annotation to @JMS\XmlList(inline=true, entry="customer")

Marçal Berga
  • 305
  • 1
  • 11