API16

API16:JXMLElement/getAttribute

From Joomla! Documentation

Revision as of 22:56, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== LEGACY - Gets an elements attribute by name. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JXMLElement/getAttribute|Edit Descript...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

LEGACY - Gets an elements attribute by name.

[Edit Descripton]

Template:Description:JXMLElement/getAttribute

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;
}

[Edit See Also] Template:SeeAlso:JXMLElement/getAttribute

Examples

<CodeExamplesForm />

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