The XPath Access Mechanism

The XPath part of the solution makes accessing the elements within the XML document much easier than a traditional event-driven or even DOM-based parser. To use the XPath interface is simplicity itself. For example, to get a list of all the subelements, you need to do is access the elements property of the parent element. The each method accepts an XPath definition that in turn returns a list of all the subelements that it finds. For example, you can work through all the items using this...

Tcl and Unicode

The TclXML parser will read Unicode encoded documents directly, so you need to identify or display either entities or character data. Then you will need to be able to translate between Unicode formats. Tcl 8.1 and after includes the encoding command, which will convert strings between the different encoding formats for you. See the following sidebar for information on determining which encodings are supported by your system. To determine which encodings are supported by your Tcl installation,...

Generating XML with AppleScript

You can build an XML document by creating the record and then using the generate XML command to dump the record as an XML string. You can see a simple example of an AppleScript script for this in Listing 23.9. O Listing 23.9 Generating XML from an XML Record class XML element, -XML tag MchapterM, -XML attributes - title XML and AppleScript, - chapnumber 03 , -XML contents - class XML element, -XML tag MparagraphM, -XML contents - The output of the script is shown in Listing 23.10. O Listing...

Entity References

Entity references are merely ways of introducing a standard piece of text by name, rather than explicitly within the text itself. There are two reasons for using entities. The first is to get around the problem of introducing characters into character data that would otherwise be identified as special XML characters. The second is to provide an easy means for introducing repeating elements of text into your XML documents without the risk of introducing errors. This first problem is covered in...