Jsonix Purchase Order Working Example

HTML

<script src="https://rawgithub.com/highsource/jsonix/master/dist/Jsonix-all.js"></script>
<h1>Unmarshalling</h1>
<h2>Original XML</h2>
<pre id="originalXML"></pre>
<h2>Unmarshalled JS Object</h2>
<pre id="unmarshalledJS"></pre>
<hr/>
<h1>Marshalling</h1>
<h2>Original JS Object</h2>
<pre id="originalJS"></pre>
<h2>Marshalled XML</h2>
<pre id="marshalledXML"></pre>

JavaScript

var xmlUrl = '/gh/get/response.xml/highsource/jsonix/tree/master/fiddles/po/';

Jsonix.DOM.load(xmlUrl, function(originalXML) {
    $('#originalXML').text(Jsonix.DOM.serialize(originalXML));
}, { method : 'POST', headers: { 'X-Requested-With': 'XMLHttpRequest' } });
               

var PO = {
    name: 'PO',
    typeInfos: [{
        type: 'classInfo',
        localName: 'PurchaseOrderType',
        propertyInfos: [{
            type: 'element',
            name: 'shipTo',
            elementName: 'shipTo',
            typeInfo: 'PO.USAddress'
        }, {
            type: 'element',
            name: 'billTo',
            elementName: 'billTo',
            typeInfo: 'PO.USAddress'
        }, {
            type: 'element',
            name: 'comment',
            elementName: 'comment',
            typeInfo: 'String'
        }, {
            type: 'element',
            name: 'items',
            elementName: 'items',
            typeInfo: 'PO.Items'
        }, {
            name: 'orderDate',
            typeInfo: 'Calendar',
            attributeName: 'orderDate',
            type: 'attribute'
        }]
    }, {
        type: 'classInfo',
        localName: 'Items',
        propertyInfos: [{
            type: 'element',
            name: 'item',
            collection: true,
            elementName: 'item',
            typeInfo: 'PO.Item'
        }]
    }, {
        type: 'classInfo',
        localName: 'USAddress',
        propertyInfos: [{
            type: 'element',
            name: 'name',
            elementName: 'name',
            typeInfo: 'String'
        }, {
            type: 'element',
            name: 'street',
            elementName: 'street',
            typeInfo: 'String'
        }, {
            type: 'element',
            name: 'city',
            elementName: 'city',
            typeInfo: 'String'
        }, {
            type: 'element',
            name: 'state',
            elementName: 'state',
            typeInfo: 'String'
     ...