पीएचपी ऐडचाइल्ड () फंक्शन
उदाहरण
<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 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 |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | एक SimpleXMLElement ऑब्जेक्ट जो XML नोड में जोड़े गए बच्चे का प्रतिनिधित्व करता है |
---|---|
पीएचपी संस्करण: | 5.1.3+ |
❮ PHP SimpleXML संदर्भ