how read the data from XML file using php
file, html, php, xml
Solution
You have to look at the structure of the XML, you need to do
echo $xml->MESSAGES->MESSAGE->RECIPIENT_NUM."<br>";
Problem
I Have a XML file which have data's in it,i want to reading the XML file get values and display the values,i am trying to display RECIPIENT_NUM and TEMPLATE ,but now i able to display only the TEMPLATE but i can't able to display the RECIPIENT_NUM.below is my code can any one guide me to display the RECIPIENT_NUM,thanks XML ``` <?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <VERSION>2.0</VERSION> <INVOICE_NUM>33</INVOICE_NUM> <PIN>14567894</PIN> <MESSAGE_TYPE>INSTANT_SEND</MESSAGE_TYPE> <COUNTRY_CODE>xxxxxxx</COUNTRY_CODE> <TEMPLATE>Dear Mrs Braem, this is a message from xxxxxxx. Kindly call us regarding your cleaning appoitnment tomorrow at 9.30. Thanks and Regards</TEMPLATE> <DATABASEINFO> <DATABASE_NAME>xxxxxx</DATABASE_NAME> <CLINIC_ID>1</CLINIC_ID> </DATABASEINFO> <MESSAGES> <MESSAGE> <SEND_DATE>2013-12-15</SEND_DATE> <ENTITY_ID>0</ENTITY_ID> <RECIPIENT_NUM>xxxxxxx</RECIPIENT_NUM> <MESSAGE_PARAMS /> </MESSAGE> </MESSAGES> <CSUM>ffd6c84a1a89a0f2ebc8b1dc8ea1f4fb</CSUM> </DOCUMENT> ``` PHP ``` <html> <body> <?php $xml=simplexml_load_file("/data/data/www/Message.xml"); print_r($xml); echo $xml->TEMPLATE . "<br>"; echo $xml->RECIPIENT_NUM."<br>"; ?> </body> </html> ```