PHP addChild() လုပ်ဆောင်ချက်
ဥပမာ
ကလေးဒြပ်စင်ကို <body> ဒြပ်စင်နှင့် <footer> ဒြပ်စင်အသစ်သို့ ထည့်ပါ-
<?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 a child element to the body element
$xml->body->addChild("date","2014-01-01");
// Add a child element after the last element inside note
$footer = $xml->addChild("footer","Some footer text");
echo $xml->asXML();
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
addChild() လုပ်ဆောင်ချက်သည် ကလေးဒြပ်စင်တစ်ခုကို SimpleXML ဒြပ်စင်သို့ ပေါင်းထည့်သည်။
အထားအသို
SimpleXMLElement::addChild(name, value, ns)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
name | Required. Specifies the name of the child element to add |
value | Optional. Specifies the value of the child element |
ns | Optional. Specifies a namespace for the child element |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | XML node တွင် ထည့်သွင်းထားသော ကလေးအား ကိုယ်စားပြုသည့် SimpleXMLElement အရာဝတ္ထု |
---|---|
PHP ဗားရှင်း- | 5.1.3+ |
❮ PHP SimpleXML အကိုးအကား