www.webdeveloper.com
Results 1 to 10 of 10

Thread: What is the purpose of XML?

  1. #1
    Join Date
    Jun 2008
    Posts
    30

    What is the purpose of XML?

    What can this language do that others such as HTML, CSS, or PHP can't do?

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    The latest version of Microsoft Office now uses XML for its file formats. They are Word documents and Excel spreadsheets etc and not web pages and so can't use HTML but they can use XML because you can define whatever tags you need with XML and are not limited to those just for web pages.

    You can also have information stored as XML that is fed through one filter to create a web page of that content and a completely different filter to produce the same content for a completely different media.

    XML is also the ideal intermediate format for transferring data between any other formats. Say you have 10 different programs that need to be able to share data and each has its own proprietary format. To convert from any one proprietary format to any other directly would require 90 different filters to do the possible conversions. Converting to and from XML would only require 20. There are a lot more than 10 different programs in the world that people want to share data between.
    Stephen

  3. #3
    Join Date
    May 2008
    Posts
    381
    felgall essentially explained the uses for it. The concept is that XML is a text-based data storage method. You can use whatever markup you want:
    Code:
    <inventory xmlns="urn:ABCo">
        <purchaseDate>2008-06-22</purchaseDate>
        <deliveryDate>2008-06-25</deliveryDate>
        <item invNumber="38C-192" name="Lid - 32oz Coffee">
            <quantity>3</quantity>
            <description>Lids for 32oz coffee cups</description>
        </item>
        <item invNumber="08N-231" name="Napkins - White">
            <quantity>4</quantity>
            <description>8oz pkg. of white pre-folded napkins</description>
        </item>
    </inventory>
    Simple, right? Elements or attributes, it doesn't matter. They could have been done just as easily either way. Sometimes it makes more sense to use one instead of the other, but occasionally the choice isn't terribly easy.

    You can define a grammar using an XML DTD, an XML Schema, a Relax NG schema, or any combination thereof, so that any document created using that format must conform specifically to that grammar.

    You can transform it into HTML, XML, XHTML or possibly even a simple text format like CSV using XSLT documents.

    You can still style it using CSS as well.

    I will say that XML languages are not programming languages, per se, like PHP or C++ are. Things like XPath are simply tools used to aid in the programming aspect of using the XML document. XSLT is simply an XML-based grammar used to manipulate the way XML should be rendered.

  4. #4
    Join Date
    Jun 2008
    Posts
    1

    Ultimate Purpose of XML

    Encode (mark up) data only once (not once per product)
    Construct many products from that markup
    Reuse data (in whole or part) many times
    print publications
    websites and online syndication
    ebooks and publishing to other devices (PDAs)
    electronic archives for search and reuse
    new product opportunities

  5. #5
    Join Date
    Oct 2007
    Location
    USA
    Posts
    73
    To be honest, you're unlikely to get any "epiphany moments" until you actually start using it. And I don't mean you make an inventory of your personal library and then sit back and look at a screen full of XML. That's not really putting it to use. I mean making that data DO something. And believe me, there are thousands of applications designed to take XML inputs and deliver it as outputs.

    The easiest thing to do IMO is to make some XML, link an XSLT to it, and then turn it into a web page (XHTML). Beyond that, the sky's the limit, but XSLT is one of the earliest and easiest things you can use to make your XML DO something. Believe me, you're not going to develop an appreciation for the technology if you're not doing something with it. I know that was my biggest hurdle.

    In web development, XML can be useful by being dynamically generated on the server, sent to the client browser along with an XSLT, and recompiled into (X)HTML on the client side, taking some burden off the server.

    Personally, I find XSL's ability to script JavaScript makes working with XML data down right fun. Possibilities are endless here. And pretty much everywhere else.

  6. #6
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    The 'epiphany moment' will most likely occur when you set up a second XSLT that converts the XML into another format (such as a Word document) allowing you to have the same XML source producing 2 (or 1,000) different formats for the same data so that it can be used everywhere you need to without having to rewrite anything. Make changes to the XML and all the different formats are updated automatically.
    Stephen

  7. #7
    Join Date
    Jul 2008
    Posts
    3
    You guys seem to be very knowledgeable in XML, so can you shed some light on how the search engines can deal with dynamically rendered pages from XML data files? I'm planning a wikipaedia-type site and really need to get a handle on this.

    Thanks.

  8. #8
    Join Date
    Aug 2007
    Posts
    3,767
    Just make sure that you use GET variables to dynamically load the page, not POST. As far as I know, GET will be indexed, POST will not.
    Great wit and madness are near allied, and fine a line their bounds divide.

  9. #9
    Join Date
    Sep 2004
    Location
    At the corner of WALK and DONT WALK
    Posts
    1,714
    One use I found for XML was containing information to be parsed with PHP. There is absolutely no presentation information for this type of file; that is not its purpose. Its purpose is to contain commentary too long to be easily edited in PHPMyAdmin

  10. #10
    Join Date
    Oct 2007
    Location
    USA
    Posts
    73
    Quote Originally Posted by felgall
    ... allowing you to have the same XML source producing 2 (or 1,000) different formats for the same data so that it can be used everywhere you need to without having to rewrite anything.
    Also another awesome feature of XML. The idea that content should be separate from form is embodied in XML. One content source, thousands of potentially different formats.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles