<?xml version="1.0" encoding="UTF-8"?>
<FLOOR>
<FLOOR1>
<BlOCK ID="F5" NAME="HallMark" URL="F1.COM"/>
<BlOCK ID="F6" NAME="F6" URL="F1.COM"/>
<BlOCK ID="F7" NAME="U.S. Polo Assn." URL="F1.COM"/>
</FLOOR1>
<FLOOR2>
<BlOCK ID="G4" NAME="Daiso" URL="G1.COM"/>
<BlOCK ID="G5" NAME="Lakhoos Exchange" URL="G1.COM"/>
<BlOCK ID="G6" NAME="4u" URL="G1.COM"/>
<BlOCK ID="G7" NAME="Aldo" URL="G1.COM"/>
<BlOCK ID="G8" NAME="Athlete's co." URL="G1.COM"/>
</FLOOR2>
</FLOOR>
以上是我的 XML 文件。我想用 ID =G8 或说 ID=F7 更新“名称”的元素值。请帮忙。我尝试了很多代码。但失败了
I tried this .. but it returns empty.
$xmlFile = file_get_contents('floormap.xml');
//$xml = simplexml_load_string($xmlFile);
$new= new SimpleXMLElement($xmlFile);
$n=$new->xpath('//FLOOR1/B1OCK[@ID="F1"]');
var_dump($n);