Siemka, mam problem z usunięciem elementu w pliku XML, chciałbym usunąć wybrany element "<main>"... 1, 2 lub 3 chodzi o całą zawartość main'a
plik xml:
<main>
<first>1</first>
<second>1</second>
<third>1</third>
<fourth>1</fourth>
<fifth>1</fifth>
</main>
<main>
<first>2</first>
<second>2</second>
<third>2</third>
<fourth>2</fourth>
<fifth>2</fifth>
</main>
<main>
<first>3</first>
<second>3</second>
<third>3</third>
<fourth>3</fourth>
<fifth>3</fifth>
</main>
<main>
<first>4</first>
<second>4</second>
<third>4</third>
<fourth>4</fourth>
<fifth>4</fifth>
</main>
</root>
tutaj mam kod dodawania elementów do pliku xml
if (isset($_POST['insert']))
{
$xml = new DomDocument("1.0","UTF-8");
$xml -> load('xml.xml');
$first = $_POST['first'];
$second = $_POST['second'];
$third = $_POST['third'];
$fourth = $_POST['fourth'];
$fifth = $_POST['fifth'];
$rootTag = $xml ->getElementsByTagName("root")->item(0);
$mainTag = $xml -> createElement("main");
$firstTag = $xml ->createElement("first", $first);
$secondTag = $xml ->createElement("second", $second);
$thirdTag = $xml ->createElement("third", $third);
$fourthTag = $xml ->createElement("fourth", $fourth);
$fifthTag = $xml ->createElement("fifth", $fifth);
$mainTag ->appendChild($firstTag);
$mainTag ->appendChild($secondTag);
$mainTag ->appendChild($thirdTag);
$mainTag ->appendChild($fourthTag);
$mainTag ->appendChild($fifthTag);
$rootTag ->appendChild($mainTag);
$xml ->save('xml.xml');
}
?>
<html>
<body>
<form method="POST" action = "insertxml.php">
Student info <br/>
First: <input type="text" name = "first"><br/>
Second: <input type = "text" name = "second" > <br/>
Third: <input type = "text" name = "third" > <br/>
Fourth: <input type = "text" name = "fourth" > <br/>
Fifth: <input type = "text" name = "fifth" > <br/>
<input type="submit" name="insert" value="add">
</form>
</body>
</html>
Liczę na rozwiązanie lub wskazówkę.