changeset 53375:e085973399ee

(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.
author Eli Zaretskii <eliz@is.elta.co.il>
date Mon, 29 Dec 2003 12:11:49 +0000
parents 910142cb21d6
children 305881e6e0cd
files lisp/xml.el
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/xml.el	Mon Dec 29 12:05:15 2003 +0000
+++ b/lisp/xml.el	Mon Dec 29 12:11:49 2003 +0000
@@ -104,15 +104,24 @@
 	      (push child match))))
     (nreverse match)))
 
-(defun xml-get-attribute (node attribute)
+(defun xml-get-attribute-or-nil (node attribute)
   "Get from NODE the value of ATTRIBUTE.
-An empty string is returned if the attribute was not found."
+nil is returned if the attribute was not found.
+
+See also `xml-get-attribute'."
   (if (xml-node-attributes node)
       (let ((value (assoc attribute (xml-node-attributes node))))
 	(if value
 	    (cdr value)
-	  ""))
-    ""))
+	  nil))
+    nil))
+
+(defsubst xml-get-attribute (node attribute)
+  "Get from NODE the value of ATTRIBUTE.
+An empty string is returned if the attribute was not found.
+
+See also `xml-get-attribute-or-nil'."
+  (or (xml-get-attribute-or-nil node attribute) ""))
 
 ;;*******************************************************************
 ;;**