PHP addAttribute()函数讲解
时间:2021-05-28 08:02:42|栏目:PHP代码|点击: 次
PHP addAttribute() 函数
实例
给根元素和 body 元素添加一个属性:
<?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);
$xml->addAttribute("type","private");
$xml->body->addAttribute("date","2013-01-01");
echo $xml->asXML();
?>
定义和用法
addAttribute() 函数给 SimpleXML 元素添加一个属性。
语法
addAttribute( _name,value,ns_ );

总结






