Try to search your question here, if you can't find : Ask Any Question Now ?

Edit and save simple XML by php

HomeCategory: stackoverflowEdit and save simple XML by php
Avatarpragati asked 4 months ago

I found this script and it works, but I would like to edit all the children, not just the first one.
It’s possible?

<script src=""></script>
$xml = new DOMDocument('1.0', 'utf-8');
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;

//Get item Element
$element = $xml->getElementsByTagName('global')->item(0);

//Load child elements
$name = $element->getElementsByTagName('data')->item(0);

//Replace old elements with new
$element->replaceChild($name, $name);


if (isset($_POST['submit']))
$name->nodeValue = $_POST['namanya'];



<form method="POST" action=''>
<p><?php echo $name->nodeValue  ?></p><input type="text-name" value="<?php echo $name->nodeValue  ?>" name="namanya" />
<input name="submit" type="submit" />

The format of my xml documents is :


  <data name="title"><![CDATA[data1]]></data>
  <data name="author_name"><![CDATA[data2]]></data>



1 Answers
Best Answer
AvatarJyoti answered 4 months ago
Your Answer

2 + 20 =

Popular Tags

WP Facebook Auto Publish Powered By :