skcratch Posted September 15, 2009 at 08:08 PM Report Share #287190 Posted September 15, 2009 at 08:08 PM Viva! Neste momento, tenho a seguinte string XML: <?xml version="1.0" encoding="UTF-8"?> <communication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <command name="CommandResponse"/> <response name="OK" data="Opcional" description="Opcional"/> </communication> Aquilo que pretendia era obter o atributo do name (neste caso concreto, OK) recorrendo ao SimpleXML. Será que alguém pode dar uma ajuda? Cumps! B) Link to comment Share on other sites More sharing options...
yoda Posted September 15, 2009 at 08:14 PM Report Share #287192 Posted September 15, 2009 at 08:14 PM <?php $xml = simplexml_load_file($ficheiro); foreach($xml->response[0]->attributes() as $attribute => $value) { if ($attribute == 'name') echo $value; } ?> before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
skcratch Posted September 15, 2009 at 08:27 PM Author Report Share #287194 Posted September 15, 2009 at 08:27 PM Viva! Funcionou na perfeição. Mais uma vez, muito obrigado pela ajuda. Cumps! B) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now