Ben bu XML var:
<picture id="2">
<title>B</title>
</picture>
<picture id="3">
<title>C</title>
</picture>
<picture id="0">
<title>A</title>
</picture>
Bunu başarmak için çalışıyor:
<picture id="1">
<title>B</title>
</picture>
<picture id="2">
<title>C</title>
</picture>
<picture id="0">
<title>A</title>
</picture>
'Id' nitelik değerleri bir listesini almak için bu kullanma:
$objXML = new SimpleXMLElement(XML_FILE_NAME, null, true);
$picture = $objXML->xpath('picture');
$arrayCurrent = array();
foreach($picture as $value) {
$arrayCurrent[] = (string)$value['id'];
}
sort($arrayCurrent); // put XML into numerical 'id' order
print_r($arrayCurrent);
It returns: Array ( [0] => 0 [1] => 2 [2] => 3 ) Any ideas how to re-index like so: 0, 1, 2 and save the appropriate 'id' attributes back to their correct positions in the XML doc?
Teşekkürler, Andy