File: xml.el.html
This file contains a somewhat incomplete non-validating XML parser. It parses a file, and returns a list that can be used internally by any other Lisp libraries.
; FILE FORMAT
The document type declaration may either be ignored or (optionally) parsed, but currently the parsing will only accept element declarations. The XML file is assumed to be well-formed. In case of error, the parsing stops and the XML file is shown where the parsing stopped.
It also knows how to ignore comments and processing instructions.
The XML file should have the following format:
<node1 attr1="name1" attr2="name2" ...>value
<node2 attr3="name3" attr4="name4">value2</node2>
<node3 attr5="name5" attr6="name6">value3</node3>
</node1>
Of course, the name of the nodes and attributes can be anything. There can
be any number of attributes (or none), as well as any number of children
below the nodes.
There can be only top level node, but with any number of children below.
; LIST FORMAT
The functions xml-parse-file, xml-parse-region and
xml-parse-tag return a list with the following format:
xml-list ::= (node node ...)
node ::= (qname attribute-list . child_node_list)
child_node_list ::= child_node child_node ...
child_node ::= node | string
qname ::= (:namespace-uri . "name") | "name"
attribute_list ::= ((qname . "value") (qname . "value") ...)
| nil
string ::= "..."
Some macros are provided to ease the parsing of this list. Whitespace is preserved. Fixme: There should be a tree-walker that can remove it.
TODO:
* xml:base, xml:space support
* more complete DOCTYPE parsing
* pi support
Defined variables (8)
xml-default-ns | Alist mapping default XML namespaces to their URIs. |
xml-entity-alist | Alist mapping XML entities to their replacement text. |
xml-entity-expansion-limit | The maximum size of entity reference expansions. |
xml-parameter-entity-alist | Alist of defined XML parametric entities. |
xml-sub-parser | Non-nil when the XML parser is parsing an XML fragment. |
xml-syntax-table | Syntax table used by the XML parser. |
xml-undefined-entity | What to substitute for undefined entities. |
xml-validating-parser | Set to non-nil to get validity checking. |
Defined functions (25)
xml--entity-replacement-text | (STRING) |
xml--parse-buffer | (PARSE-DTD PARSE-NS) |
xml-debug-print | (XML &optional INDENT-STRING) |
xml-debug-print-internal | (XML INDENT-STRING) |
xml-escape-string | (STRING &optional NOERROR) |
xml-get-attribute | (NODE ATTRIBUTE) |
xml-get-attribute-or-nil | (NODE ATTRIBUTE) |
xml-get-children | (NODE CHILD-NAME) |
xml-maybe-do-ns | (NAME DEFAULT XML-NS) |
xml-node-attributes | (NODE) |
xml-node-children | (NODE) |
xml-node-name | (NODE) |
xml-parse-attlist | (&optional XML-NS) |
xml-parse-dtd | (&optional PARSE-NS) |
xml-parse-elem-type | (STRING) |
xml-parse-file | (FILE &optional PARSE-DTD PARSE-NS) |
xml-parse-region | (&optional BEG END BUFFER PARSE-DTD PARSE-NS) |
xml-parse-string | () |
xml-parse-tag | (&optional PARSE-DTD PARSE-NS) |
xml-parse-tag-1 | (&optional PARSE-DTD PARSE-NS) |
xml-print | (XML &optional INDENT-STRING) |
xml-remove-comments | (BEG END) |
xml-skip-dtd | () |
xml-substitute-numeric-entities | (STRING) |
xml-substitute-special | (STRING) |