This is my XML file.
<body>
<div>
<p time="00:00:08"> </p>
<p time="00:00:10"> </p>
<p time="00:00:13"> </p>
</div>
</body>
Now I want to add time = “00:00:12” to the XML file, but in increasing order.
So, before adding this time, I will have to compare the time with other times and then add it at appropriate location.
Can anybody suggest me how to do this. A sample code would very helpful.
As was suggested in Gordon’s answer, I would load the XML file into SimpleXML, append the node and then sort it.
I’ve commented the code below to explain it step-by-step.