AddChild PHP function ()
Podręcznik PHP SimpleXML referencyjny
Przykłady
elementów nadwozia i stopki Aby dodać element elementy podrzędne:
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=new SimpleXMLElement($note);
// Add a child element to the body element
$xml->body->addChild("date","2013-01-01");
// Add a child element after the last element inside note
$footer=$xml->addChild("footer","Some footer text");
echo $xml->asXML();
?>
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=new SimpleXMLElement($note);
// Add a child element to the body element
$xml->body->addChild("date","2013-01-01");
// Add a child element after the last element inside note
$footer=$xml->addChild("footer","Some footer text");
echo $xml->asXML();
?>
Uruchomienie instancji »
Definicja i Wykorzystanie
Funkcja addChild () w celu dodania elementu podrzędnego elementu SimpleXML.
gramatyka
addChild( name,value,ns );
参数 | 描述 |
---|---|
name | 必需。规定要添加的子元素的名称。 |
value | 可选。规定子元素的值。 |
ns | 可选。规定子元素的命名空间。 |
dane techniczne
Zwraca: | Zwraca Dodaj do obiektu SimpleXMLElement w elementach podrzędnych XML. |
---|---|
Wersja PHP: | 5.1.3+ |
Podręcznik PHP SimpleXML referencyjny