arok
arok

Reputation: 1845

how read the data from XML file

I Have a XML file which have messages and mobile number in it,i reading the XML file get values and display the values ,but now i able to display only the message but i can't able to display the mobile number.below is my code can any one guide me to do this,thanks

my Message.xml file looks like

[TEMPLATE] => Dear xxxxxxx, this is a message from xxxxxxx. Kindly call us regarding your appoitnment tomorrow at 9.30. 
[RECIPIENT_NUM] => 0xxxxxxxxxx

php code

<?php
$xml=simplexml_load_file("/data/data/www/Message.xml");
print_r($xml);

echo $xml->TEMPLATE . "<br>";
echo $xml->RECIPIENT_NUM ."<br>";
?>  

Upvotes: 2

Views: 137

Answers (2)

James
James

Reputation: 10432

Try the following: This will turn the xml into an object so you can access the content directly.

$path = @file_get_contents($url);
$xml = @simplexml_load_string($path);

Follow the example here. http://www.w3schools.com/php/php_xml_simplexml.asp

Upvotes: -1

cnh003
cnh003

Reputation: 144

The XML should look something like this

<xml>
  <template>Template</template>
  <recipient_num>Number</recipient_num>
</xml>

Just look into the tutorial: http://www.w3schools.com/xml/

Upvotes: 2

Related Questions