用PHP解析xml文件,我想根据用户需要通过jQuery删除元素
这是我的xml文件,它是自动生成的。我想解析它,然后修改内容,但首先我想执行删除操作,但它对我不起作用用PHP解析xml文件,我想根据用户需要通过jQuery删除元素,php,jquery,xml,Php,Jquery,Xml,这是我的xml文件,它是自动生成的。我想解析它,然后修改内容,但首先我想执行删除操作,但它对我不起作用 <?xml version="1.0"?> <Guide TotalPages="1"> <guideTitle>TestMe</guideTitle> <guideName>hawreGuide2014030516131719</guideName> <Page number="1"> &
<?xml version="1.0"?>
<Guide TotalPages="1">
<guideTitle>TestMe</guideTitle>
<guideName>hawreGuide2014030516131719</guideName>
<Page number="1">
<content type="Statement">Statment for test</content>
<content type="Question Type1" option1='op1' option2='op2'>Can you answer?</content>
<content type="Question Type5" option1="Multiple choice1" option2="Multiple choice2" option3="Multiple choice3" option4="" option5="">Multiple choice</content>
</Page>
</Guide>
知道吗,或者我做错什么了?非常感谢您的帮助。检查ID和类
这个echo'代码>和这个$(“.pageSheet”)
不一样
使用echo'代码>插入
if (file_exists('../xmlpages/hawreGuide2014030516131719.xml')) {
$xml = simplexml_load_file('../xmlpages/hawreGuide2014030516131719.xml');
} else {
exit('Failed to open test.xml.');
}
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "<br>";
if($child->getName() == 'Page')
{
foreach($child->attributes() as $key => $value) {
echo $value.'<br/>';
echo"<div id='pageSheet'> ";
}
}
foreach($child->children() as $subchild)
{
echo"<br/><p>";
echo "The question is :::<input type='text' value='". $subchild ."'> " . $subchild ."<br>";
foreach($subchild->attributes() as $key => $value) {
if($key =='type')
{
echo "Key ".$key." Value ".$value.'<br/>';
}
else
{
echo "Key ".$key." Value<input type='text' value='". $value ."'> ".$value.'<br/>';
}
}
echo"<button class='deleteCon'> Delete</button></p><br/>";
}
echo"</div>";
}
?>
$(".pageSheet").on("click", ".deleteCon", function () {
$(this).closest("p").remove(); });