您好我想找到一个带有文本字符串“CAT1”的xml节点并显示但我似乎无法正确使用它。有人可以告诉我什么是错的。
--- ---的catalog.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Catalog>
<Category>
<Name>CAT1</Name>
<Location>
<Room> Alpha </Room>
</Location>
</Category>
<Category>
<Name>CAT2</Name>
<Location>
<Room> Bravo </Room>
</Location>
</Category>
<Category>
<Name>CAT3</Name>
<Location>
<Room> Charlie </Room>
</Location>
</Category>
<Category>
<Name>CAT4</Name>
<Location>
<Room> Delta </Room>
</Location>
</Category>
</Catalog>
--- --- arr0.php
<?php
$catalog = simplexml_load_file("catalog.xml");
$category = $catalog->Category;
$name = $category->Name;
$location = $category->Location;
$room = $location->Room;
for ($i = 0; $i <= 22; $i++)
{
$display = $catalog->xpath("//Category/Name[contains(text("CAT1"),'".$category[$i]->$name."']/parent::");
{
echo $display;
echo $room;
}
}
?>
结果是显示节点[类别] [名称] = CAT1,[位置] [房间]下列出的所有详细信息,但我显示错误
解析错误:语法错误,第11行/home/a3440614/public_html/arr0.php中的意外T_STRING
任何有助于纠正和简化它的帮助。
由于