PHP, XML How to get attributes?

joshuaiguana

New Member
I am trying to return the values of the SECTION attribute of the INTRO tags from the following xml:sample of myxml.xml:\[code\]<INTRO SECTION="ONE"> <TEXT>Hello</TEXT></INTRO><INTRO SECTION="TWO"> <TEXT>Goodbye</TEXT></INTRO>\[/code\]my php:\[code\]$doc = new DOMDocument();$doc->load('myxml.xml');$intros = $doc->getElementsByTagName("INTRO");foreach( $intros as $intro ) {echo $intro ->get_attribute('SECTION');}\[/code\]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.... J
 
Back
Top