From 9bcd6a7e9486d68f612fe179073868bfa2ed6563 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 29 Dec 2003 12:13:27 +0000 Subject: [PATCH] (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. --- lisp/ChangeLog | 7 +++++++ lisp/xml.el | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 336a1b8e7b8..df852fc5b13 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2003-12-29 Mark A. Hershberger + + * xml.el (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. + 2003-12-29 Eli Zaretskii * emacs-lisp/easymenu.el (easy-menu-define): Doc fix. 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." (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) "")) ;;******************************************************************* ;;** -- 2.39.2