untitled

(ff) #1
10.2 Transforming XML 245

For DOM lists one uses theitemmethod.
DOM uses the single word “node” for anything that can occur in an XML
document. Elements, attributes, and text content are all examples of DOM
nodes. There are many methods of DOM nodes. The following are the most
important methods:


  • getAttribute. The value of one attribute of an element.

  • getChildNodes. A DOM list consisting of all the nodes contained in an
    element.

  • getFirstChild. The first child node in an element.

  • getParentNode. The containing element.


Summary


  • The whole document style of XML processing reads the entire document
    into a single Perl data structure.

  • DOM methods are used to extract information from an XML document.

  • The entities that occur in an XML document are represented by DOM
    nodes.

  • DOM lists are used for holding a collection of DOM nodes.


10.2.4 Producing XML


While it is becoming increasingly common for bioinformatics data to be rep-
resented in XML, it is still the case that large amounts of data are still (and
will continue to be) in various text formats. As a result, one common task
will be to convert from text formats to XML format. This section is concerned
with transformations from text files to XML. This can be done in Perl by the
same kind of command that was used for transforming text files to text files;
namely, a command such as this:
perl program.perl file.txt ... > result.xml

except that the result file is an XML file.
The programs in this section consider input file formats and XML struc-
tures that get progressively more complex. The early ones use simple flat
(record) structures, and the later ones consider more complex structures.
Consider that health study again:
Free download pdf