# HG changeset patch # User Eli Zaretskii # Date 1072699909 0 # Node ID e085973399ee74dd910c69e51979006f13ab4fd8 # Parent 910142cb21d61d7aee2eb956df8cab09b32424fb (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. diff -r 910142cb21d6 -r e085973399ee lisp/xml.el --- 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) "")) ;;******************************************************************* ;;**