PHP addAttribute() လုပ်ဆောင်ချက်
ဥပမာ
အရင်းဒြပ်စင် (<မှတ်ချက်>) နှင့် <body> ဒြပ်စင်သို့ ရည်ညွှန်းချက်တစ်ခု ထည့်ပါ-
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Do not forget me this weekend!</body>
</note>
XML;
$xml = new SimpleXMLElement($note);
// Add attribute to root element
$xml->addAttribute("type","private");
// Add attribute to body element
$xml->body->addAttribute("date","2014-01-01");
echo $xml->asXML();
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
addAttribute() လုပ်ဆောင်ချက်သည် SimpleXML ဒြပ်စင်သို့ ရည်ညွှန်းချက်တစ်ခု ထပ်လောင်းသည်။
အထားအသို
SimpleXMLElement::addAttribute(name, value, ns)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
name | Required. Specifies the name of the attribute to add |
value | Optional. Specifies the value of the attribute |
ns | Optional. Specifies a namespace for the attribute |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဘာမှမဖြစ် |
---|---|
PHP ဗားရှင်း- | 5.1.3+ |
❮ PHP SimpleXML အကိုးအကား