I am trying to return the values of the SECTION attribute of the INTRO tags from the following xml:
Sample of myxml.xml:
<INTRO SECTION="ONE">
<TEXT>Hello</TEXT>
</INTRO>
<INTRO SECTION="TWO">
<TEXT>Goodbye</TEXT>
</INTRO>
My PHP:
$doc = new DOMDocument();
$doc->load('myxml.xml');
$intros = $doc->getElementsByTagName("INTRO");
foreach( $intros as $intro ) {
echo $intro ->get_attribute('SECTION');
}
I am getting the following error:
Call to undefined method DOMElement::get_attribute()
Does anyone know what I am doing wrong? Kind regards to any responders.