PHP xpath() ပုံစံ

အသုံးပြုခြင်း နှင့် အကြောင်းကြား

xpath() ပုံစံ အား XPath ရှာဖွေခြင်း မှတ်ချက်ပြုသည်。

အောင်မြင်ခဲ့လျှင် SimpleXMLElement အရာများ ပါဝင်သော စကာတင် တစ်စုံတစ်ရာ ပြန်လည်ပေးသည်။ အကြောင်းပြချက် မရှိပါ။

ပုံစံ

class SimpleXMLElement
{
string xpath(path)
}
ပါဝင်သည် ဖော်ပြ
path စည်းကမ်းရန်ဖြစ်သည်။ XPath လမ်းကြောင်း。

အကျိုးဆက်

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
$xml = simplexml_load_file("test.xml");
$result = $xml->xpath("from");
print_r($result);
?>

ထုတ်လုပ်ခြင်း:

Array
(
[0] => SimpleXMLElement Object
  (
  [0] => John
  )
)