addChild()
PHP addChild() funksiyasi
❮ PHP SimpleXML ma’lumotnomasi
Misol
<body> elementiga bola element va yangi <footer> elementini qo‘shing:
<?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();
?>
Misolni ishga tushirish »
Ta’rif va qo‘llanilishi
addChild() funksiyasi SimpleXML elementiga bola element qo‘shadi.
Sintaksis
SimpleXMLElement::addChild(name, value, ns)
Parametr qiymatlari
| Parametr | Tavsif |
|---|---|
| name | Majburiy. Qo‘shiladigan bola element nomini belgilaydi |
| value | Ixtiyoriy. Bola element qiymatini belgilaydi |
| ns | Ixtiyoriy. Bola element uchun nomlar fazosini (namespace) belgilaydi |
Texnik tafsilotlar
| Qaytariladigan qiymat: | XML tuguniga qo‘shilgan bola elementni ifodalovchi SimpleXMLElement obyekti |
|---|---|
| PHP versiyasi: | 5.1.3+ |
❮ PHP SimpleXML ma’lumotnomasi
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
