I have written code that accepts orders then writes them to XML.
I can create two formats of XML, one is bespoke to our CRM, the other is opXML under BOSS standards.
My final createXML function is entirely different for each format because the structure and element names differ.
Here are short extracts to demonstrate
As you can see, as well as different elements names the hierarchy is also different.
I would like a generic function that could write either format depending on the function parameters.
Passing this associtive array seems a good start
But I cannot think of a way to pass the structure/hierarchy to match the elements.
Any tips gratefully considered.
I can create two formats of XML, one is bespoke to our CRM, the other is opXML under BOSS standards.
My final createXML function is entirely different for each format because the structure and element names differ.
Here are short extracts to demonstrate
Code:
-------opXML--------
<InvoiceLine>
<LineNumber>1</LineNumber>
<InvoiceLineReferences />
<Product>
<SuppliersProductCode>XX-XX-XX</SuppliersProductCode>
<Description>nnnnnnnnnnnnnnnnn</Description>
</Product>
<Quantity>
<Amount>2</Amount>
</Quantity>
<Price>
<UnitPrice>35.5000</UnitPrice>
<LineTotalNet>71.00</LineTotalNet>
<LineTotalTax>12.43</LineTotalTax>
<LineTotal>83.43</LineTotal>
</Price>
<LineTax />
</InvoiceLine>
Code:
------Bespoke---------
<OrderLine>
<LineNumber>1</LineNumber>
<Product>XXX-XXX</Product>
<Quantity>1</Quantity>
<Price>7.7900</Price>
<Personalised />
<DiscValue />
<LineTotalGross>7.79</LineTotalGross>
<LineTotalNet />
<LineTotalTax />
</OrderLine>
I would like a generic function that could write either format depending on the function parameters.
Passing this associtive array seems a good start
Code:
array(element name1=>value, element name2=>value, element name3=>value)
Any tips gratefully considered.
Comment