Mathias Brodala: Namensraum ermitteln

Beitrag lesen

Hallo nochmal.

$str_doc = '<?xml version="1.0" encoding="utf-8"?>

<title type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  xhtml:div
    Less: xhtml:em &lt; </xhtml:em>
  </xhtml:div>
</title>';

$obj_doc = new DOMDocument();
$obj_doc->loadXML($str_doc);

echo $obj_doc->getElementsByTagName('div')->item(0)->lookupPrefix('http://www.w3.org/1999/xhtml'); # → xhtml

  
Ich sehe gerade, dass die letzte Zeile noch etwas einfacher geht:  
  
`echo $obj_doc->getElementsByTagName('div')->item(0)->[link:http://www.php.net/manual/en/ref.dom.php#dom.class.domnode.properties@title=prefix];`{:.language-php}  
  
Dies entspricht eher dem, was du suchtest, oder Thomas?  
  
  
Einen schönen Montag noch.  
  
Gruß, Mathias  

-- 
sh:( fo:} ch:? rl:( br: n4:~ ie:{ mo:| va:) de:> zu:} fl:( ss:) ls:[ js:|  
„It is required that HTML be a common language between all platforms. This implies no device-specific markup, or anything which requires control over fonts or colors, for example. This is in keeping with the SGML ideal.“  
[[HTML Design Constraints: Logical Markup](http://www.w3.org/History/19921103-hypertext/hypertext/WWW/MarkUp/HTMLConstraints.html)]