<?php
$dom
=
new
DOMDocument();
$dom
->loadXML("<?xml version=\"1.0\"?>
<root>
<div xmlns:x=\"my_namespace\">
<x:h1 x:style=\"color:red;\">
Hello, this is my red heading.
</x:h1>
<x:h1 x:style=\"color:green;\">
Hello, this is my green heading.
</x:h1>
<x:h1 x:style=\"color:blue;\">
Hello, this is my blue heading.
</x:h1>
</div>
<div xmlns:y=\"another_namespace\">
<y:h1 y:style=\"color:red;\">
Hello, this is my
new
red heading.
</y:h1>
<y:h1 y:style=\"color:green;\">
Hello, this is my
new
green heading.
</y:h1>
<y:h1 y:style=\"color:blue;\">
Hello, this is my
new
blue heading.
</y:h1>
</div>
</root>");
$nodeList
=
$dom
->getElementsByTagNameNS(
'my_namespace'
,
'h1'
);
foreach
(
$nodeList
as
$node
) {
echo
$node
->getAttribute(
'x:style'
) .
'<br>'
;
}
?>