पीएचपी 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 |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | कुछ भी तो नहीं |
---|---|
पीएचपी संस्करण: | 5.1.3+ |
❮ PHP SimpleXML संदर्भ