diff options
| author | Eli Zaretskii | 2003-12-29 12:13:27 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2003-12-29 12:13:27 +0000 |
| commit | 9bcd6a7e9486d68f612fe179073868bfa2ed6563 (patch) | |
| tree | 02a647c1c169aa6cfba60717c9fc8945613d467e /lisp/xml.el | |
| parent | dffafab0865acfdfaed232b9c91166b501d079f6 (diff) | |
| download | emacs-9bcd6a7e9486d68f612fe179073868bfa2ed6563.tar.gz emacs-9bcd6a7e9486d68f612fe179073868bfa2ed6563.zip | |
(xml-get-attribute-or-nil): New function, like
xml-get-attribute, but returns nil if the attribute was not found.
(xml-get-attribute): Converted to defsubst, uses
xml-get-attribute-or-nil.
Diffstat (limited to 'lisp/xml.el')
| -rw-r--r-- | lisp/xml.el | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/xml.el b/lisp/xml.el index a6159554b3f..b025a546a48 100644 --- a/lisp/xml.el +++ b/lisp/xml.el | |||
| @@ -104,15 +104,24 @@ CHILD-NAME should be a lower case symbol." | |||
| 104 | (push child match)))) | 104 | (push child match)))) |
| 105 | (nreverse match))) | 105 | (nreverse match))) |
| 106 | 106 | ||
| 107 | (defun xml-get-attribute (node attribute) | 107 | (defun xml-get-attribute-or-nil (node attribute) |
| 108 | "Get from NODE the value of ATTRIBUTE. | 108 | "Get from NODE the value of ATTRIBUTE. |
| 109 | An empty string is returned if the attribute was not found." | 109 | nil is returned if the attribute was not found. |
| 110 | |||
| 111 | See also `xml-get-attribute'." | ||
| 110 | (if (xml-node-attributes node) | 112 | (if (xml-node-attributes node) |
| 111 | (let ((value (assoc attribute (xml-node-attributes node)))) | 113 | (let ((value (assoc attribute (xml-node-attributes node)))) |
| 112 | (if value | 114 | (if value |
| 113 | (cdr value) | 115 | (cdr value) |
| 114 | "")) | 116 | nil)) |
| 115 | "")) | 117 | nil)) |
| 118 | |||
| 119 | (defsubst xml-get-attribute (node attribute) | ||
| 120 | "Get from NODE the value of ATTRIBUTE. | ||
| 121 | An empty string is returned if the attribute was not found. | ||
| 122 | |||
| 123 | See also `xml-get-attribute-or-nil'." | ||
| 124 | (or (xml-get-attribute-or-nil node attribute) "")) | ||
| 116 | 125 | ||
| 117 | ;;******************************************************************* | 126 | ;;******************************************************************* |
| 118 | ;;** | 127 | ;;** |