XML

XML = Extensible Markup Language

HTML minus the formatting information. Designed to convey information rather than layout.

Example:

    <?xml version="1.0"?>
    <ADDRESS>
        <NAME>Dave Brankin</NAME>
        <LINE1>10 Somewhere Road</LINE1>
        <TOWN>Somewhere</TOWN>
        <POSTCODE>AB1 1AB</POSTCODE>
    </ADDRESS>

Well-formed XML

Note: "Well-formed XML" is a term, not a description!

Using XML with IE

XML can be processed within IE using an ActiveX object:

    var myXMLDoc = new ActiveXObject("Microsoft.XMLDOM")
    myXMLDoc.async=false                <--- controls whether entire file has to be read before processing starts
    myXMLDoc.load("myfile.xml")
    var rootElement = cmlDox.documentElement
    mySpan.innerText = rootElement.childNodes.item(0).text

I'm not going into further details as (a) I think we're unlikely to use this client-side approach with the .NET infrastructure and (b) I think ActiveX in browsers may be a bit of a no-no for some clients.

Data Islands

XML incorporated within a HTML document is referred to as a "data island". Basically, just encase the XML in the <XML> tag. The ID attribute of the <XML> tag is used to give us the required "hook" into the data. For example:

<HTML>
...
<XML ID="dave">
    <PERSON>
        <FORENAME>Dave</FORENAME>
        <SURNAME>Brankin</SURNAME>
    </PERSON>
</XML>
....
    var xml=dave
    var root = xml.documentElement
    mySpan.innerText=root.childNodes.item(0).text
...

Note: No ActiveX component! ?? So why did we need one earlier? ?? The "var xml=dave" line performs the equivalent operation.

Note: The <XML> tag also supports the SRC attribute which allows an external XML file to be specified.