php xml to array
![]() |
php xml to array |
this is very simple codes to convert php xml to array..
create xml file: file.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <? xml version = "1.0" ?> < user_info > < title >Users Information</ title > < totalRows >3</ totalRows > < rows > < user > < name >ANJAN KUMAR</ name > < email >Anjankumardhali@gmail.com</ email > < education >Physics</ education > </ user > < user > < name >Palash Mondal</ name > < email >Palsh@mail.com</ email > < education >Computer Science</ education > </ user > < user > < name >Nikita Adikary</ name > < email >Niki@nikita.com</ email > < education >Software Engineering</ education > </ user > </ rows > </ user_info > |
Create php file to access xml file: xml_to_array.php
1 2 3 4 5 6 7 8 9 10 11 12 | <?php //xml file path $path = "file.xml" ; //read entire file into string $xmlfile = file_get_contents ( $path ); //convert xml string into an object $xml = simplexml_load_string( $xmlfile ); $json = json_encode( $xml ); //convert into associative array $xmlArr = json_decode( $json , true); print_r( $xmlArr ); ?> |
That's it friends how to convert xml to array using php..if you like this post please share with your friends..Thank You..
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.