Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用PHP解析xml文件,我想根据用户需要通过jQuery删除元素_Php_Jquery_Xml - Fatal编程技术网

用PHP解析xml文件,我想根据用户需要通过jQuery删除元素

用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文件,它是自动生成的。我想解析它,然后修改内容,但首先我想执行删除操作,但它对我不起作用

<?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(); });