Actions

API16

JXMLElement/getAttribute

< API16:JXMLElement

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

LEGACY - Gets an elements attribute by name.



Syntax

getAttribute($name)
Parameter Name Default Value Description
$name $name

Returns

string

Defined in

libraries/joomla/utilities/xmlelement.php

Importing

jimport( 'joomla.utilities.xmlelement' );

Source Body

public function getAttribute($name)
{
        return (string)$this->attributes()->$name;
}



Examples

Code Examples

Get the attribute of an element

demo.xml

<jdoc>
	<doku kategory="Info">Wiki</doku>
</jdoc>
<?php
 
$xml = JFactory::getXML('demo.xml');
 
echo $xml->doku->getAttribute('kategory');
 
/* Better: */
echo $xml->doku->attributes()->kategory;

Output:

Info

Elkuku 11:16, 14 January 2011 (CST) Edit comment
Advertisement