Thread Rating:
  • 662 Vote(s) - 2.74 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML1:XML Data
06-16-2011, 09:56 AM, (This post was last modified: 06-20-2011, 04:45 PM by kino.)
#1
XML1:XML Data
Most data can be transformed into XML content. This provides a drive to use XML as a medium for structuring information the Web for the purpose of data exchange between applications. XML structures data using a text-based markup language similar to HTML and is non-proprietary and platform independent. Open standards and the focus on communication and collaboration among people and applications have created and environmnet where XML Web services are becoming a standard platform for application integration in the move to distributed computing on the Internet. From a Curl client perspective, XML information can be obtained from communicating with a Web service over HTTP or using XML over HTTP.



In either case, the data that is queried and obtained is XML. Therefore it is necessary to first concentrate on handling XML data in the Curl client over HTTP. Once these fundamental principles are understood, then we will access XML data via a Web service in a subsequent Curl Cue.


Curl's XML Document Model


Curl's XML Document Model (XDM) provides functionality for processing XML data in Curl: reading, creating, modifying and writing XML documents. XML document contents are represented as a hierarchy of Curl objects which can be accessed using Curl methods and XPath expressions. Once accessed, the contrent can be displayed, transformed, and processed to meet the application functionality


Curl's XDM is accessible through the Curl Web Services Development Kit (WSDK). The WSDK library must be installed and accessed in order to use access its functionality which include SOAP/WSDL support, and an XML document model. If you plan on displaying and manipulating the examples contained within this Curl Cue, there is no need to download the WSDK. However, once you download and run the examples on your local machine, you will need to download the libraray.


You can download the WSDK library from the official WSDK download page by selecting the following link: WSDK Download.


XDM Nodes


The XDM views XML documents as a tree structure of elements embedded within other elements. All elements, their containing text and their attributes can be accessed through the XDM structure. Their contents can be modified, deleted, and new elements can be created. The elements, associated text and attributes are modeled as nodes.


In the WSDK, XDMNodes are represented by XDMElements, XDMAttributes, XDMText, XDMProcessingIstructions.



Displaying the XML DOM Structure


In the first example, we read the XML, store the data as an XDM document, and then display the data using a tree control structure that allows you to visually expand and compress the XML nodes. This method is very useful during development, but not as common in production applications.


Steps: the quickest way to read and view the XML data is to:

1.Import necessary WSDK packages

2.Create an XML Document model (XDMDocument) using the build-xml procedure.

3.Display the stored XML data using XDMTreeControl

In this example we use XML data created directly in the code using the xml-string variable for simplicity.


width='100%' height='550' src='/wiki/samples/generic-example.curl?WSDKSamples/XML/xmldata.curl'



Note that 2 packages need to be imported from the WSDK:

•COM.CURL.WSDK.XML-DOCUMENT-MODEL: this allows us to access XDMDocument

•COM.CURL.WSDK.XML-DISPLAY: this allows us to access XDMTreeControl





In the second example, we query the XML data from a known Url. This scenario is typical of what you would expect from a deployed application where the xml data resides on a company server.


For this example, the XML data is stored in the file sample.xml. It represents an inventory or resources from the Widgets/Gadgets/Curlets section on Curl's Developer Community (www.developers.curl.com).

Code:
curl
Hardware-accelerated rendering is used to show a 3D view of chemical molecules.
http://developers.curl.com/docs/DOC-1060
http://developers.curl.com/demos/molecules/start.curl



curl
This example displays flames by simulating them mathematically, not just by showing a series of precomputed images.
http://developers.curl.com/docs/DOC-1057
http://developers.curl.com/demos/fire/start.curl



curl
The teapot is a classic example of 3D rendering.
http://developers.curl.com/docs/DOC-1059
http://developers.curl.com/demos/teapot/start.curl

Note: the full list code samples can be found here: Widgets/Gadgets/Curlets.


width='100%' height='390' src='/wiki/samples/generic-example.curl?WSDKSamples/XML/xmldata2.curl'





About build-xml: The build-xml function uses the standard Curl SAX parser and has corresponding keyword arguments. The input source can be specified as a Url or a String, as well as text and byte streams.


The XDMTreeControl displays and exact representation of the XML using a tree structure of elements embedded within other elements. If the XML data had multiple levels, the tree control nodes would expand to view all children.


Since the XDM presents stores XML data as a tree structure, it gives us access to the information through a set of objects. This allows us to query relevant information, transform and process the data, and display the requested information to the user. Thus, we can state the the XDM model is needs to be obtained first before any processing can occur. The following Curl Cues will discuss methods of transformation and display.


Attached Files
.png   CurlClientXML.png (Size: 21.34 KB / Downloads: 2,599)
.png   XDMNodes.png (Size: 18.02 KB / Downloads: 1,969)
05-25-2012, 06:56 AM,
#2
RE: XML1:XML Data
Do will have a similar "Clue" page on JSON ?

thanks


Robert Shiplett, Curlr
Fredericton NB

Canada
01-12-2013, 03:44 PM,
#3
RE: XML1:XML Data
Nice discussion .... Thanks
10-21-2013, 12:48 PM,
#4
RE: XML1:XML Data
I agree allthis post. I really impressed by it.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Persistent Data1:Client-side Persistent Data kino 0 6,565 06-15-2011, 05:24 PM
Last Post: kino
  Files over HTTP4:Viewing RecordSet Data kino 0 4,859 06-15-2011, 04:46 PM
Last Post: kino
  Files over HTTP3:Connected Data kino 0 7,072 06-15-2011, 04:42 PM
Last Post: kino
  Files over HTTP2:Organizing Data using RecordSets kino 0 5,492 06-15-2011, 04:35 PM
Last Post: kino
  User Interface Basics4:Populating Control List Data kino 0 3,709 06-15-2011, 03:58 PM
Last Post: kino
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('32')