From 118wiki

Jump to: navigation, search


Everyone's heard of the eXtensible Markup Language, you probably know it is somehow related to HTML, and the Wiki overview (see XML) has many details. Here, we can look at some things you are less likely to immediately know.

  1. XML is just one, in a progression, of standards for a "universal" standard for data representation. An earlier one, sometimes covered in network textbooks, is the ASN.1 standard; ASN.1 is a binary standard, whereas XML uses characters and therefore is easier for humans to read and edit; the price for this is that the representation can waste bandwidth.
  2. XML, despite having been a "hot" topic, is not universally loved. For example, see this or this.
  3. There are even recent alternatives to XML, some with Python support, for instance JSON (or JSON); these alternatives are less expressive or less powerful than XML, but have some other advantages in being easier to parse or simpler to manage.
  4. XML can be abused, or used where it really should not be used, as pointed out in this opinion.
  5. You probably have to use XML even if you don't like it (as stated here).

Python's XML Support

Many programming languages offer standard tools and APIs for reading, writing, and searching XML, which gets to be a significant topic itself. There seems to be a mismatch between the database world, which favors relational databases where data fits in tables with rows of data and organized columns, and the XML world of representation. One thing's the same, we need to search databases (using SQL) and repositories of XML data (using an XML query tool). There are significant classes of similar problems using XML, such as translating from one style of XML to another. If you need to work with many XML documents, repositories of XML documents, nested XML or other complications, you're better off using the specialized tools and languages.

But you can experiment with XML, using Python programs, to get some idea of how all these tools do their job.

  1. Start by getting familiar with XML concepts.
  2. If you like, you can read the first chapter of a book on the subject of Python and XML: here, where you learn of Python's support of the DOM API, which parses XML into a tree representation.
  3. Study a Python DOM tutorial and get some feel for how the API works.
  4. Then take a small XML document, and use the Python API to read the document, perhaps change one or two things in the document, and write it out.
  5. If you have the time, you could look at a previous lecture (flash presentation).
Personal tools