$catalog = new SimpleXMLElement(file_get_contents($file));
foreach($catalog->stores->store as $arStore){
$name = (string)$arStore['name'];
}
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<stores>
<store uid="111" name="444">
<store uid="222" name="555">
<store uid="333" name="666">
</store></store></store></stores></catalog>
read its attributes (and how to read the attributes of the first store? I loop through the elements and I have read both (and in this case, 3 elements, attributes)) - added to store in the output file
read 2 store - set up in RF.
read the attributes added to store 2-mu in the R. f.
It's logic, but in practice the first element of the array with the key store and its attributes are transferred to all store elements of the result file - nikita.Stracke commented on June 8th 19 at 16:52
in $catalog->stores->store stores the current item, when working in a loop the current element is updated to the next
and in the cycle of moving things in the right order
not quite understand what you need, but before the foreach loop, declare the counter which record the current iteration and on this basis to do the necessary manipulations with the data.
from the first store, you can read the attributes
so
echo (string)$catalog->stores->store['name']
or so
echo (string)$catalog->stores->store[0]['name']
- Rose_Rodrigu commented on June 8th 19 at 16:55Could You throw a working code (example)
Here's the file file1.xml copy the bitmap to a file file2.xml with all the attributes.
Then I could broadcast on your work your decision.
- nikita.Stracke commented on June 8th 19 at 16:58