I need to save some values from XML.
First step - I get the structure:
$xml = $dom_xml->saveXML();
$xml_ = new \SimpleXMLElement($xml);
dd($xml_);
Here TextFrame
has 8 arrays. Each of them has PathPointType
, which has
4 more arrays with 3 attributes each. And these attributes I need from each TextFrame
.
I can get, for instance, Anchor
value doing this:
$res = $xml_
->Spread
->TextFrame
->Properties
->PathGeometry
->GeometryPathType
->PathPointArray
->PathPointType
->attributes();
dd($res['Anchor']);
(BTW: is there more prettier way to get it?)
But the question is - how is it possible to loop through all arrays and save values separately for each array?
I assume here has to be a multidimensional foreach
loop in conjunction with for
loop?
Or is better to achieve it using DOMDocument
?