I have a function that is generating XML for a contract last web service(not my choice).
public function generateXml($endorsements)
{
$xmlstr = '
<?xml version="1.0" encoding="utf-8" ?>
<is:CaptureRQ xmlns:dg="urn:digimarc.com:SchemaTypes" DataVersion="1.6" XsdSchemaValidatable="true" xmlns:is="urn:digimarc.com:imaging">
<is:Endorsements>
<is:Code>
<dg:Value>'.$endorsements.'</dg:Value>
</is:Code>
</is:Endorsements>
</is:CaptureRQ>';
return $xmlstr;
}
The thing is, the $endorsements variable is an array. For every item in the array I need to create a new element:
<is:Endorsements>
<is:Code>
<dg:Value>'.$endorsements.'</dg:Value>
</is:Code>
</is:Endorsements>
I know ths is a hacked up way of doing things, but I’ve been locked into this by the vendor. I’m really not sure how to do this. Thank you guys for your help in advance.
Further Example
Just to be clear, here’s an example.
generateXml(array(a,b,c));
Would output:
<is:Endorsements>
<is:Code>
<dg:Value>a</dg:Value>
</is:Code>
</is:Endorsements>
<is:Endorsements>
<is:Code>
<dg:Value>b</dg:Value>
</is:Code>
</is:Endorsements>
<is:Endorsements>
<is:Code>
<dg:Value>c</dg:Value>
</is:Code>
</is:Endorsements>
Where a smaller array would be:
generateXml(array(a,b));
This would output:
<is:Endorsements>
<is:Code>
<dg:Value>a</dg:Value>
</is:Code>
</is:Endorsements>
<is:Endorsements>
<is:Code>
<dg:Value>b</dg:Value>
</is:Code>
</is:Endorsements>
Hows this?