The following example shows how to handle a situation in which an XML document contains multiple data values that are represented by only one data structure in the Microsoft Dynamics NAV database. For an XMLport Sales Order example, see XMLport Sales Order Example.

Example

In this example, the XML sales order document from which you want to import data into the table contains two nodes <ShipDate> and <ShipTime>, as shown in the following.

  CopyCode imageCopy Code
<?xml version="1.0" ?>
  <SalesOrder>
	<OrderHeader OrderDate="17-09-04">
	<SellTo CountryRegion="GB">
		<Name>The Cannon Group PLC</Name>
		<Address>192 Market Square</Address>
		<City>Birmingham</City>
		<Zip>B27 4KT</Zip>
	</SellTo>
	<BillTo CountryRegion="GB">
		<Name>The Cannon Group PLC</Name>
		<Address>192 Market Square</Address>
		<City>Birmingham</City>
		<Zip>B27 4KT</Zip>
		<PaymentTerms>14days</PaymentTerms>
	</BillTo>
	</OrderHeader>
	<Items>
	<Item PartNum="LS-75">
		<ProductName>Loudspeaker, Cherry, 75W</ProductName>
		<Quantity>10</Quantity>
		<UnitPrice>79</UnitPrice>
		<ShipDate>12-10-04</ShipDate>
		<ShipTime>09:50</ShipTime>
		<Comment>Confirm the voltage is 75W</Comment>
	</Item>
	<Item PartNum="1908-8">
		<ProductName>LONDON Swivel Chair, blue</ProductName>
		<Quantity>12</Quantity>
		<UnitPrice>190,926</UnitPrice>
		<ShipDate>12-10-04</ShipDate>
		<ShipTime>09:50</ShipTime>
	</Item>
	</Items>
  </SalesOrder>

One solution to the problem in this example is to cache the values in the <ShipDate> and <ShipTime> nodes, format the two values into a DateTime value, and assign the formatted value to the Shipping Time field in the Sales Lines table. In XMLport Designer, you would define the <ShipDate> and <ShipTime> nodes as being of the Text source type.

Node name Node type Source type Data source

ShipDate

Element

Text

<ShipDate>

ShipTime

Element

Text

<ShipTime>

In the OnAfterAssignVariable trigger for the <ShipTime> node, you would write code that formats the two text variables into one DateTime variable and assigns the value held by that variable to the Shipping Time field in the Sales Lines table.

See Also