I am completely new to the XML parsing topic and I would like to ask, if there is any framework class or extension that would allow me read and parse XML file.
Is here any out-of-the-box solution or must one write it itself in i.e. SimpleXML?
I am completely new to the XML parsing topic and I would like to ask, if there is any framework class or extension that would allow me read and parse XML file.
Is here any out-of-the-box solution or must one write it itself in i.e. SimpleXML?
What do you need which PHP core libraries does not provide?
I need to “convert” a bit complex XML structure into JSON.
SimpleXML core library does really provide everything that you need. I only wanted to confirm, if I have to craft everything from scratch (loops, finding correct tokens using regular expressions probably etc.) or if there is something ready out-of-the-box in Yii 2.
I don’t like reinventing the wheel idea, so I wanted to double check, if I am not making something like that, before I write my one XML → JASON and XML → model data parsers.
Am not aware of any!
May be check for XML libs for PHP in general
Looks to me like a desktop application.
I was asking about PHP class or Yii 2 extension etc.
What do you need it for? You can load it in simple XML change it to JSON and finally to array and process it with Yii classes. If it is something sensitive then work with simple XML.
This is a 1,5 year old question and my projects are shifting quite rapidly, so honestly saying I don’t remember anymore, what was the main purpose!
For sure two aspects were in the scope:
I think it was something around this. Thanks!
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
Once you get arrays like the above method then you can assign attributes
$model->attributes = $rray_from_simple_xml_conversion;