IT/라라벨
[php] xml 포맷 데이터 배열로 바꾸기
_이준호_
2020. 8. 18. 17:40
Xml 파일을 파싱해야 할 일이 있어서 패키지를 사용해봤는데 xml 파일 데이터 읽어들이는데서 계속 문제가 생겨서
php 함수를 써서 해결했다
내가 썼던 패키지
https://github.com/orchestral/parser
orchestral/parser
[Package] XML Document Parser for Laravel and PHP. Contribute to orchestral/parser development by creating an account on GitHub.
github.com
https://github.com/sergiorodenas/stream-parser
sergiorodenas/stream-parser
⚡ PHP7 / Laravel Multi-format Streaming Parser. Contribute to sergiorodenas/stream-parser development by creating an account on GitHub.
github.com
난 위의 두개 패키지 다 오류가 떠서 밑에 방법으로 해결하였다
$xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);