\Header{xmlGetAttr}{Get the value of an attribute in an XML node}
\keyword{file}{xmlGetAttr}
\begin{Description}\relax
This is a convenience function that retrieves
the value of a named attribute in an XML node,
taking care of checking for its existence.
It also allows the caller to provide a default
value to use as the return value if the
attribute is not present.
\end{Description}
\begin{Usage}
\begin{verbatim}
xmlGetAttr(node, name, default = NULL, converter = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{node}] the XML node
\item[\code{name}] the name of the attribute
\item[\code{default}] a value to use as the default return if the attribute
is not present in the XML node. 
\item[\code{converter}] an optional function which if supplied is invoked
with the attribute value and the value returned.
This can be used to convert the string to an arbitrary
value which is useful if it is, for example, a number.
This is only called if the attribute exists within the node.
In other words, it is not applied to the \code{default} value.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This just checks that the attribute list is
non-NULL and that there is an element with
the specified name.
\end{Details}
\begin{Value}
If the
attribute is present,
the return value is  a string which is the value of the attribute.
Otherwise, the value of \code{default} is returned.
\end{Value}
\begin{Author}\relax
Duncan Temple Lang
\end{Author}
\begin{References}\relax
\url{http://www.w3.org/XML}, \url{http://www.jclark.com/xml},
\url{http://www.omegahat.org}
\end{References}
\begin{SeeAlso}\relax
\code{\Link{xmlAttrs}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
 node <- xmlNode("foo", attrs=c(a="1", b="my name"))

 xmlGetAttr(node, "a")
 xmlGetAttr(node, "doesn't exist", "My own default value")

 xmlGetAttr(node, "b", "Just in case")
\end{ExampleCode}
\end{Examples}

