Extract attribute from simple XML element in PHP

SakClaila

New Member
Driving me bonkers- I've got a simple XML element, and I just want to extract the '_Code' attribute. How would I do it?\[code\]<?php$responseCode = "<STATUS _Condition='FAILURE' _Code='0705' _Description='Search failed subject not found' />";$xml = simplexml_load_string($responseCode);print_r($xml);$code = $xml=>@attributes=>_Code; // Parse error$code = $xml['@attributes']['_Code']; // Returns blankecho "CODE = ".(string)$code; ?>\[/code\]\[quote\] CODE =\[/quote\]http://php.net/manual/en/function.simplexml-load-string.php
 
Back
Top