我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

php XMLreader:编辑元素属性和值

How I edit the attributes or values of an XML element?

the file:

<element>
  <apple type="fruit">red</apple>
</element>


XMLreader:

        $xml= new XMLReader();
        $xml->open($file);

        while($xml->read()){
            if($xml->nodeType == XMLReader::ELEMENT) {
                if($xml->getAttribute('type') == "fruit") {

                       //change attr. and values to:
                       //apple = cabbage, fruit = vegetable, red = white

                }
            }               
        }

Well, in order to edit XML, you must not use a reader class ;-)


Instead, take a look at DOMDocument or SimpleXML.

近期文章

  • php转义用户输入以在html中显示
  • PHP和MySQL商店距离计算器 - 邮政编码
  • 目录选择器
  • PHP处理图像并在页面加载时首先显示它
  • PHP挑选推文代码
  • 如何在jquery(jcarousel)中保留图像集
  • 数据映射器设计模式和网关 - 新手问题
  • 用户注册设计
  • Facebook - 网站集成
  • jquery ajax和php session
  • 在Python中模拟HTTP Post请求
  • cakephp中的群组
  • 不要在vim中替换内部的php-strings
  • 在递增数字中找到第一个1/2然后第一个整体
  • 我的mod-rewrite改变url是行不通的
  • 如何调整此功能以允许抖动?
  • 基于Radio Button Click的jQuery Autocalculate
  • 我可以在重定向到新页面之前设置POST变量吗? [重复]
  • 将信息插入文件时,是否必须保护用户的输入?
  • 减少php网上商店的数据库调用

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华