SYNOPSISstring xmlReaderGetAttribute(xmlReader reader, string name
[, string nsURI])
Parameters:
xmlReader
- the xmlReader
objectname
- the name of the attribute whose value you
wantnsURI
(optional) - The URI or the namespace for
the attribute. Defaults to any namespace.
Returns:
DESCRIPTIONxmlReaderGetAttribute()
gets the value of a specific attribute on
the current element.
If no nsURI
is given, then the qualified name (ns prefix:local
name) is used, and the namespace URI is not considered. If a
nsURI
is given, then the attribute with that local name in the
nsURI
namespace will be fetched, regardless of prefix.
EXAMPLE<capture>
<?xml version="1.0"?>
<top attr1="attr1 noNS" myns:attr1="attr1 myns"
xmlns:myns="urn:nsExample"/>
</capture><$xml = $ret>
<$reader = (xmlReaderNewFromString($xml))>
<!-- move to the first element -->
<$ret = (xmlReaderRead($reader))>
<$val1 = (xmlReaderGetAttribute($reader, 'attr1'))>
no ns, no prefix: ($val1)
<$val2 = (xmlReaderGetAttribute($reader, 'myns:attr1'))>
no ns, myns prefix: ($val2)
<$val3 = (xmlReaderGetAttribute($reader, 'attr1', ''))>
blank ns: ($val3)
<$val4 = (xmlReaderGetAttribute($reader, 'attr1',
'urn:nsExample'))>
nsExample ns: ($val4)
Will produce the following output:
no ns, no prefix: (attr1 noNS)
no ns, myns prefix: (attr1 myns)
blank ns: (attr1 noNS)
nsExample ns: (attr1 myns)
SEE ALSOxmlReaderGetAttributeCount
,
xmlReaderGetAttributeNumber