Front End XML For ASP Developers - Data Exchange
(Page 2 of 5 )
Today, XML is often the language (or format, in this case) of choice for most companies when it comes to exchanging data between applications. This includes batch processes, server to client feeds, custom application-level protocols and a host of other cases.
A great example of such a process is a data feed of all orders taken electronically via a web site into an internal billing and shipping system. The main advantage of XML here is it's flexibility - developers create their own tags and dictionaries, as they deem necessary. Therefore no matter what type of data is being transferred, the right XML representation of it will accurately describe the data.
Let's examine one of the most widely used formats here, a sample version of a Yahoo! Merchant "Order Download File", which is an XML representation of orders received by a Yahoo web-front store in a specified period of time.
This sample is available for download from Yahoo at
http://store.yahoo.com/lib/vw/OrderList.xml
Logically, each order can be described as one customer purchasing one or more items using their credit card and potentially entering different billing and shipping addresses. Every file will contain multiple orders, like this:
<OrderList StoreAccountName="scr-test-485.0123456789ABCDEF">
<Order id="scr-test-485">
...
</Order>
<Order id="scr-test-486">
...
</Order>
</OrderList>The contents of the file are very easy to read, even for a person who is not familiar with XML. The information within each of the order tags is well structured and organized. This enables developers to use parsing components and easily access any data within the document. Here's a sample of how shipping information is represented:
<AddressInfo type="ship">
<Name>
<First>Sheridan</First>
<Last>Rawlins</Last>
<Full>Sheridan Rawlins</Full>
</Name>
<Address1>321 Foo bar lane</Address1>
<Address2>Apartment #2</Address2>
<City>Nowhere</City>
<State>CA</State>
<Country>US United States</Country>
<Zip>12345</Zip>
<Phone>555.444.3210</Phone>
</AddressInfo>Each item in the order is logically a unique entity, and is also represented with a separate tag. All item properties are defined as "child" nodes of the item tag. This also helps in both reading the code and parsing the data:
<Item num="0">
<Id>auspowworran</Id>
<Code>12345</Code>
<Quantity>1</Quantity>
<Unit-Price>1000000.00</Unit-Price>
<Description>Austin Power's World Ransom</Description>
<Taxable>YES</Taxable>
<Url>http://st15.yahoo.com/scr-test/auspowworran.html</Url>
</Item>XML is the language of choice for two major reasons. First of all, an XML formatted document can be easily processed under any OS, and in any language, as long as XML parsing components are available. On the other hand, XML files are still raw data, which enables merchants to format the data any way they want to, as opposed to, for example, Yahoo-formatted invoices for each order.
All in all, document structure and wide acceptance of this format has made it possible for Yahoo to enable customers to build more efficient internal order Tracking systems based on XML-formatted order files. Other online merchant sites are making similar functionality available on their Web sites as well.
Next: Configuration Files >>
More ASP Articles
More By Eugene Gilerson