Romullo7 0 Denunciar post Postado Junho 9, 2011 Ola sou novo no forum, gostaria da ajuda de voces. tenho o seguinte XML. <?xml version="1.0" encoding="utf-8" ?> <MPM> <status> <code>0</code> <message>OK</message> </status> <mediapoints><mediapoint> <protocol>2.0</protocol> <ID>8476</ID> <mediapointID>8476</mediapointID> <alias>igreja</alias> <mediatype>2</mediatype> <server></server> <viewpath>mms:///igreja</viewpath> <max_bwidth>-1</max_bwidth> <cur_bwidth>0</cur_bwidth> <max_clients>-1</max_clients> <cur_viewers>0</cur_viewers> <active>active</active> <status>active</status> </mediapoint> </mediapoints> </MPM> Gostaria de ler um unico dado em um php <cur_viewers>0</cur_viewers> como eu faço isso, ja pesquisei mais nao obtive sucesso. Agradeço desde ja. Compartilhar este post Link para o post Compartilhar em outros sites
Andrey Knupp Vital 136 Denunciar post Postado Junho 9, 2011 $XML = <<<XMLDocument <?xml version="1.0" encoding="utf-8" ?> <MPM> <status> <code>0</code> <message>OK</message> </status> <mediapoints><mediapoint> <protocol>2.0</protocol> <ID>8476</ID> <mediapointID>8476</mediapointID> <alias>igreja</alias> <mediatype>2</mediatype> <server></server> <viewpath>mms:///igreja</viewpath> <max_bwidth>-1</max_bwidth> <cur_bwidth>0</cur_bwidth> <max_clients>-1</max_clients> <cur_viewers>0</cur_viewers> <active>active</active> <status>active</status> </mediapoint> </mediapoints> </MPM> XMLDocument; $DOMDocument = new DOMDocument( '1.0', 'utf-8' ); $DOMDocument->loadXML( $XML ); echo $DOMDocument->getElementsByTagName( 'cur_viewers' )->item( 0 )->nodeValue; Compartilhar este post Link para o post Compartilhar em outros sites
Romullo7 0 Denunciar post Postado Junho 9, 2011 Eu nao tenho que colocar o link do xml nao? algo do tipo $xml = simplexml_load_file("LINK_DO_XML"); ? Desculpe sou muito leigo com isso Compartilhar este post Link para o post Compartilhar em outros sites
Andrey Knupp Vital 136 Denunciar post Postado Junho 9, 2011 você falou que tem o XML, você não sabe onde ele fica não ? Se for salvo no servidor: $DOMDocument->load( path/para/o/arquivo/no/servidor ); Se for de um url: $DOMDocument->loadXML( file_get_contents( url/do/arquivo/xml ) ); ^_^ Compartilhar este post Link para o post Compartilhar em outros sites
Romullo7 0 Denunciar post Postado Junho 9, 2011 Eu sei aonde ele fica tenho o link dele, mais aonde começa o arquivo php? to perdidin @_@ alguem?? Compartilhar este post Link para o post Compartilhar em outros sites