emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

xml.el: xml-get-attribute returns "" if not found


From: Magnus Henoch
Subject: xml.el: xml-get-attribute returns "" if not found
Date: Wed, 12 Nov 2003 22:28:19 +0100
User-agent: Mutt/1.4i

Hi,

In lisp/xml.el, the function xml-get-attribute returns "" if the requested
attribute does not exist.  To me it seems that returning nil would make
more sense in that case.  Backwards compatibilty could be achieved with
something like this:

--- xml.el.old  Mon Nov  3 22:52:15 2003
+++ xml.el      Tue Nov  4 16:53:36 2003
@@ -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) ""))
 
 ;;*******************************************************************
 ;;**

What do you think about it?

Regards,
Magnus Henoch




reply via email to

[Prev in Thread] Current Thread [Next in Thread]