Using the XML Serializer I am trying to build an array to convert to XML. The XML format I need to create has several levels with the same name.
Example:
<shipment>
<Piece>
<Pieces>5</Pieces>
<ProdID>BOXROXPTV60</ProdID>
<ProdName>Big Box 60 PTV</ProdName>
<ProdDesc></ProdDesc>
<ProdType>PDP-060</ProdType>
<PieceLength></PieceLength>
<PieceWidth></PieceWidth>
<PieceHeight></PieceHeight>
<PieceWeightActual>120</PieceWeightActual>
<PieceDecVal>2000</PieceDecVal>
<PiecePrep>Pallet</PiecePrep>
</Piece>
<Piece>
<Pieces>5</Pieces>
<ProdID>RECEIVER123</ProdID>
<ProdName>JVC Receiver 123</ProdName>
<ProdDesc></ProdDesc>
<ProdType>Receiver</ProdType>
<PieceLength>10</PieceLength>
<PieceWidth>20</PieceWidth>
<PieceHeight>5</PieceHeight>
<PieceWeightActual>20</PieceWeightActual>
<PieceDecVal>1000</PieceDecVal>
<PiecePrep></PiecePrep>
</Piece>
<ExtraSvc>
<ExtraSvcType>Install</ExtraSvcType>
<ExtraSvcValue>1</ExtraSvcValue>
</ExtraSvc>
<ExtraSvc>
<ExtraSvcType>Assembly</ExtraSvcType>
<ExtraSvcValue>1</ExtraSvcValue>
</ExtraSvc>
</shipment>
I cannot use the rootName option because there are two seperate levels that are duplicated.
The following wont work and returns:
<Piece>
<Pieces>5</Pieces>
<ProdID>BOXROXPTV60</ProdID>
<ProdName>Big Box 60 PTV</ProdName>
<ProdDesc />
<ProdType>PDP-060</ProdType>
<PieceLength />
<PieceWidth />
<PieceHeight />
<PieceWeightActual>120</PieceWeightActual>
<PieceDecVal>2000</PieceDecVal>
<PiecePrep>Pallet</PiecePrep>
</Piece>
<XML_Serializer_Tag>
<Pieces>5</Pieces>
<ProdID>RECEIVER123</ProdID>
<ProdName>JVC Receiver 123</ProdName>
<ProdDesc />
<ProdType>Receiver</ProdType>
<PieceLength>10</PieceLength>
<PieceWidth>20</PieceWidth>
<PieceHeight>5</PieceHeight>
<PieceWeightActual>20</PieceWeightActual>
<PieceDecVal>1000</PieceDecVal>
<PiecePrep />
</XML_Serializer_Tag>
$xml = Array
(
"Piece" => Array
(
"Pieces" => "5",
"ProdID" => "BOXROXPTV60",
"ProdName" => "Big Box 60 PTV",
"ProdDesc" => "",
"ProdType" => "PDP-060",
"PieceLength" => "",
"PieceWidth" => "",
"PieceHeight" => "",
"PieceWeightActual" => "120",
"PieceDecVal" => "2000",
"PiecePrep" => "Pallet"
),
Array
(
"Pieces" => "5",
"ProdID" => "RECEIVER123",
"ProdName" => "JVC Receiver 123",
"ProdDesc" => "",
"ProdType" => "Receiver",
"PieceLength" => "10",
"PieceWidth" => "20",
"PieceHeight" => "5",
"PieceWeightActual" => "20",
"PieceDecVal" => "1000",
"PiecePrep" => ""
);
Any idea how to make this work from an array?
Thanks