Actions

API16

JXMLElement/getAttribute

From Joomla! Documentation

< API16:JXMLElement
Revision as of 17:56, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

LEGACY - Gets an elements attribute by name.

[Edit Descripton]

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