API16

JXMLElement/getAttribute

From Joomla! Documentation

< API16:JXMLElement
Revision as of 17: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)

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[edit]

LEGACY - Gets an elements attribute by name.

[Edit Descripton]

Template:Description:JXMLElement/getAttribute

Syntax[edit]

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

Returns[edit]

string

Defined in[edit]

libraries/joomla/utilities/xmlelement.php

Importing[edit]

jimport( 'joomla.utilities.xmlelement' );

Source Body[edit]

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

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

Examples[edit]

<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