我如何编辑XML元素的属性或值?
文件:
<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
}
}
}