voila une des méthodes de ma classe:
private function addServices (DOMElement $entry, array $_misc) {
if ($_misc) {
// print_r ($_misc);
$segments = $this->oDoc->createElement('Segments');
$segments->setAttribute('What','Details');
// niveau inferieur
$entry = $entry->appendChild($segments);
foreach ($_misc as $service) {
$segment = $this->oDoc->createElement('Segment');
$segment->setAttribute('Quantity',count($service['occupant']));
$segment->setAttributeNS(self::XMLNS,'xsi:type','SegmentServiceType');
$entry1 = $entry->appendChild($segment);
$this->addCode($entry1,'Reference',$service['code']);
$entry2 = $entry1->appendChild($this->oDoc->createElement('Travellers'));
foreach ($service['occupant'] as $pax) {
$p = $this->oDoc->createElement('Traveller');
$p->setAttribute('Ref',$pax);
$entry2->appendChild($p);
}
}
}
}
C'est bien beau merci.Mais j'obtiens un XML de ce style:
Code : Tout sélectionner
...
<Segments>
<Segment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="Formule">
<Segments What="Details">
<Segment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SegmentServiceType" Quantity="5">
<Code Role="Reference" Value="1_MC"/>
<Travellers>
<Traveller Ref="P1"/>
<Traveller Ref="P2"/>
<Traveller Ref="P3"/>
<Traveller Ref="P4"/>
<Traveller Ref="P5"/>
</Travellers>
</Segment>
</Segments>
</Segment>
</Segments>
...Maintenant, si je commente la ligne:
$segment->setAttributeNS(self::XMLNS,'xsi:type','SegmentServiceType'); dans mon foreach, voila le résultat:
Code : Tout sélectionner
<Segment Name="Formule">
<Segments What="Details" Combination="And">
<Segment>
<Code Role="Reference" Value="5_EXC"/>
<Travellers>
<Traveller Ref="P1"/>
<Traveller Ref="P2"/>
</Travellers>
</Segment>
</Segments>
</Segment>Quelqu'un a-t-il déjà eu de tels soucis, ou y-a-t-il une raison a cela, et comment faire pour ne plus obtenir ce problême?