Function: nxml-parse-file
nxml-parse-file is a byte-compiled function defined in
nxml-parse.el.gz.
Signature
(nxml-parse-file FILE)
Documentation
Parse the XML document in FILE and return it as a list.
An XML element is represented as a list (NAME ATTRIBUTES . CHILDREN).
NAME is either a string, in the case where the name does not have a
namespace, or a cons (NAMESPACE . LOCAL-NAME), where NAMESPACE is a
symbol and LOCAL-NAME is a string, in the case where the name does
have a namespace. NAMESPACE is a keyword whose name is :URI, where
URI is the namespace name. ATTRIBUTES is an alist of attributes where
each attribute has the form (NAME . VALUE), where NAME has the same
form as an element name, and VALUE is a string. A namespace
declaration is represented as an attribute whose name is
(:http://www.w3.org/2000/xmlns/ . LOCAL-NAME). CHILDREN is a list
containing strings and child elements; CHILDREN never contains two
consecutive strings and never contains an empty string. Processing
instructions and comments are not represented. The return value is a
list representing the document element.
If the XML document is not well-formed, an error having the condition
nxml-file-parse-error will be signaled; the error data will be a
list of the form (FILE POSITION MESSAGE), where POSITION is an
integer specifying the position where the error was detected, and
MESSAGE is a string describing the error.
The current contents of FILE will be parsed even if there is a modified buffer currently visiting FILE.
If the variable nxml-validate-function is non-nil, it will be called
twice for each element, and any reported error will be signaled in the
same way as well-formedness error.
Source Code
;; Defined in /usr/src/emacs/lisp/nxml/nxml-parse.el.gz
(defun nxml-parse-file (file)
"Parse the XML document in FILE and return it as a list.
An XML element is represented as a list (NAME ATTRIBUTES . CHILDREN).
NAME is either a string, in the case where the name does not have a
namespace, or a cons (NAMESPACE . LOCAL-NAME), where NAMESPACE is a
symbol and LOCAL-NAME is a string, in the case where the name does
have a namespace. NAMESPACE is a keyword whose name is `:URI', where
URI is the namespace name. ATTRIBUTES is an alist of attributes where
each attribute has the form (NAME . VALUE), where NAME has the same
form as an element name, and VALUE is a string. A namespace
declaration is represented as an attribute whose name is
\(:http://www.w3.org/2000/xmlns/ . LOCAL-NAME). CHILDREN is a list
containing strings and child elements; CHILDREN never contains two
consecutive strings and never contains an empty string. Processing
instructions and comments are not represented. The return value is a
list representing the document element.
If the XML document is not well-formed, an error having the condition
`nxml-file-parse-error' will be signaled; the error data will be a
list of the form \(FILE POSITION MESSAGE), where POSITION is an
integer specifying the position where the error was detected, and
MESSAGE is a string describing the error.
The current contents of FILE will be parsed even if there is a
modified buffer currently visiting FILE.
If the variable `nxml-validate-function' is non-nil, it will be called
twice for each element, and any reported error will be signaled in the
same way as well-formedness error."
(with-current-buffer (nxml-parse-find-file file)
(unwind-protect
(let ((nxml-parse-file-name file))
(nxml-parse-instance))
(kill-buffer nil))))