simpleXML 简单问题

davis_rly 2012-01-09 11:24:25
Which of the following are not TRUE?

A.SimpleXML allows removal of attributes
B.SimpleXML allows addition of attributes
C.SimpleXML allows removal of nodes
D.SimpleXML allows addition of attributes
E. None of the above

一直对于simpleXML是否可以删除节点以及属性很纠结
google了一下是要通过导入到dom来操作
请大家给一点答案,最好有解释
O(∩_∩)O谢谢大家!
...全文
69 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
davis_rly 2012-01-09
  • 打赏
  • 举报
回复
D.SimpleXML allows addition of nodes
不好意思打错了
Steve 2012-01-09
  • 打赏
  • 举报
回复
B和D有什么区别吗?

正确答案是 SimpleXML allows addition of nodes and attributes.
通过 addChild和addAttribute实现。
Steve 2012-01-09
  • 打赏
  • 举报
回复
多选是BD,单选是E。
showbaixue 2012-01-09
  • 打赏
  • 举报
回复

当然是E啦 例子自己试去

<?php
$xml_str=<<<hello
<items>
<item id="100" name="csdn">
<url>www.csdn.com</url>
<time>2012.1.10</time>
</item>
</items>
hello;

$xml=simplexml_load_string($xml_str);
unset($xml->item[0]->time[0]);
unset($xml->item[0]['id']);
echo $xml->asXML();
?>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧