|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-18 12:54 UTC] jim-bugs dot php dot net at jimdabell dot com
Description:
------------
Right now, I don't think it's possible to retrieve the element type name of a simplexml_element instance. A getElementTypeName() method would be useful.
It would also be useful to have an easier way of retrieving the XML language information, as described in the XML 1.0 specification.
Reproduce code:
---------------
Right now I am using a helper function like this to get xml:lang attributes:
function getLanguage($element)
{
/* Returns the value of any xml:lang attribute when passed an element or null if there isn't one. */
$language = null;
foreach($element->attributes('http://www.w3.org/XML/1998/namespace') as $attributeName => $attribute) {
if ($attributeName == 'lang') {
$language = (string)$attribute;
}
}
return $language;
}
Obviously, that's a little unwieldy, and since the xml:lang attribute is defined in the XML 1.0 specification, it would be nice to have better support for it in PHP. Right now, as long as they are in the default namespace, it's much easier to get information about arbitrary, undefined attributes than it is about XML 1.0 standard attributes!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
Ok, it's nodeName or localName then, not ElementTypeName ;) anyway, at the moment you have to convert a simplexml node to a dom node if you want to have this info in your example, this woudl look like the following: *** $domelement = dom_import_simplexml($element); return $domelement->getAttributeNS("http://www.w3.org/XML/1998/namespace","lang"); *** No idea, if and when your wishes will be implemented...