Function: xml-parse-region

xml-parse-region is an autoloaded and byte-compiled function defined in xml.el.gz.

Signature

(xml-parse-region &optional BEG END BUFFER PARSE-DTD PARSE-NS)

Documentation

Parse the region from BEG to END in BUFFER.

Return the XML parse tree, or raise an error if the region does not contain well-formed XML.

If BEG is nil, it defaults to point-min. If END is nil, it defaults to point-max. If BUFFER is nil, it defaults to the current buffer. If PARSE-DTD is non-nil, parse the DTD and return it as the first element of the list. If PARSE-NS is non-nil, then QNAMES are expanded. By default, the variable xml-default-ns is the mapping from namespaces to URIs, and expanded names will be returned as a cons

  ("namespace:" . "foo").

If PARSE-NS is an alist, it will be used as the mapping from namespace to URIs instead.

If it is the symbol symbol-qnames, expanded names will be returned as a plain symbol namespace:foo instead of a cons.

Both features can be combined by providing a cons cell

  (symbol-qnames . ALIST).

Source Code

;; Defined in /usr/src/emacs/lisp/xml.el.gz
;;;###autoload
(defun xml-parse-region (&optional beg end buffer parse-dtd parse-ns)
  "Parse the region from BEG to END in BUFFER.
Return the XML parse tree, or raise an error if the region does
not contain well-formed XML.

If BEG is nil, it defaults to `point-min'.
If END is nil, it defaults to `point-max'.
If BUFFER is nil, it defaults to the current buffer.
If PARSE-DTD is non-nil, parse the DTD and return it as the first
element of the list.
If PARSE-NS is non-nil, then QNAMES are expanded.  By default,
the variable `xml-default-ns' is the mapping from namespaces to
URIs, and expanded names will be returned as a cons

  (\"namespace:\" . \"foo\").

If PARSE-NS is an alist, it will be used as the mapping from
namespace to URIs instead.

If it is the symbol `symbol-qnames', expanded names will be
returned as a plain symbol `namespace:foo' instead of a cons.

Both features can be combined by providing a cons cell

  (symbol-qnames . ALIST)."
  ;; Use fixed syntax table to ensure regexp char classes and syntax
  ;; specs DTRT.
  (unless buffer
    (setq buffer (current-buffer)))
  (with-temp-buffer
    (insert-buffer-substring-no-properties buffer beg end)
    (xml--parse-buffer parse-dtd parse-ns)))