13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The data island is created us<strong>in</strong>g the server control, which reads a previouslycreated <strong>XML</strong> file. The employees.xml file is simply the <strong>XML</strong> normal <strong>for</strong>m of a DataSetobject. The DataSet object is serialized to the data island, and the page is sent to thebrowser. On the client, some Javascript code takes care of extract<strong>in</strong>g the data islandcontents as <strong>XML</strong> text and pass<strong>in</strong>g it on to a method—Load—on the managed control.Internally, the Load method rebuilds the DataSet object and uses it to populate its ownuser <strong>in</strong>terface. Figure 14-4 shows the ASP.<strong>NET</strong> page <strong>in</strong> action, with a filter applied andwith the data sorted <strong>in</strong> ascend<strong>in</strong>g order by last name.Figure 14-4: Sort<strong>in</strong>g and filter<strong>in</strong>g data on the client.NoteWhen embedd<strong>in</strong>g script code <strong>in</strong> Web pages to be consumed overthe Internet, you should use the Javascript language to reach thewidest possible range of browsers. VBScript is limited to InternetExplorer. In this example, however, we're mak<strong>in</strong>g seriousassumptions about the capabilities of the client—.<strong>NET</strong> Framework<strong>in</strong>stalled, support <strong>for</strong> the extended syntax of the tag, andability to host managed code. This means that your browser mustbe Internet Explorer 5.5 or, more likely, Internet Explorer 6.0 orlater. So <strong>in</strong> this case you can reasonably drop Javascript <strong>in</strong> favor ofVBScript.From MS<strong>XML</strong> Documents to .<strong>NET</strong> <strong>XML</strong> DocumentsWhen Internet Explorer detects the tag <strong>in</strong> a client page, it automatically extractsthe page's contents, creates an <strong>in</strong>ternal <strong>in</strong>stance of the MS<strong>XML</strong> parser, and makes thedata available through an <strong>XML</strong>DOMDocument object. Note that <strong>XML</strong>DOMDocument isnot a managed object created from any of the .<strong>NET</strong> Framework classes but rather an<strong>in</strong>stance of a COM object that constitutes the <strong>XML</strong> DOM representation of the dataisland contents. The follow<strong>in</strong>g pseudocode, written <strong>in</strong> JScript, illustrates this po<strong>in</strong>t; thevariable xmldoc is an <strong>XML</strong>DOMDocument object.// Extract the data island contents// xmldoc is the ID of the tagvar xmldata = document.all("xmldoc").<strong>in</strong>nerHTML;// Instantiate MS<strong>XML</strong>499

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!