PHP simplexml_load_file() ਫੰਕਸ਼ਨ

ਪਰਿਭਾਸ਼ਾ ਅਤੇ ਵਰਤੋਂ

simplexml_load_file() ਫੰਕਸ਼ਨ XML ਦਸਤਾਵੇਜ਼ ਨੂੰ ਆਬਜਦ ਵਿੱਚ ਲਿਆ ਜਾਂਦਾ ਹੈ。

ਅਸਫਲ ਹੋਣ ਤਾਂ false ਵਾਪਸ ਦੇਣਾ。

ਗਰਮਾਤਰਾ

simplexml_load_file(file,class,options,ns,is_prefix)
ਪੈਰਾਮੀਟਰ ਵੇਰਵਾ
file ضروری، استعمال کریں گی کا XML ڈاکومن مقرر کریں
class اختیاری، نئے آئیٹم کی کلاس مقرر کریں
options اختیاری، لیبایکم پر اضافی لیبایکم پارامتر مقرر کریں
ns اختیاری
is_prefix اختیاری

بازگشتی

کلاس سیمپل ایکسمل ایک آئیٹم کا ایک آئیٹم بر آمد، جس کی خصوصیات XML ڈاکومن کے میں موجود ہیں، اگر ناکام ہو تو false بر آمد کردیگا۔

مثال

XML فائل:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>

PHP کوڈ:

<?php
if (file_exists('test.xml'))
  {
  $xml = simplexml_load_file('test.xml');
  var_dump($xml);
  }
else
  {
  exit('Error.');
  }
?>

آؤٹ پت

object(SimpleXMLElement)#1 (4)
{
["to"]=> string(4) "George"
["from"]=> string(4) "John"
["heading"]=> string(8) "Reminder"
["body"]=> string(29) "Don't forget the meeting!"
}