emacs-devel
[Top][All Lists]
Advanced

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

Re: xml-get-attribute returns "" if not found


From: Mark A. Hershberger
Subject: Re: xml-get-attribute returns "" if not found
Date: Thu, 13 Nov 2003 12:11:23 -0600
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Magnus Henoch <address@hidden> writes:

> 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.

I totally agree.  I thought I had included this change before, but I
see now that it hasn't been applied.  I recommend that the patch be
applied.

Mark.

--- 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) ""))
 
 ;;*******************************************************************
 ;;**





reply via email to

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