read xml output from php and store it in variables -


i want store values under domorder using php,like following array variable, in xml file sometime $tld[veribal][$i] may have more 1 values note : xml file if coming url

$tld[0] = dombiz; $tld[dombiz][0] = biz; $tld[1] = dominfo; $tld[dominfo][0] = info; 

xml file :

<hashtable>     <entry>     <string>domorder</string>     <map-array>       <map>         <entry>           <string>dombiz</string>           <vector>             <string>biz</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>dominfo</string>           <vector>             <string>info</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domcno</string>           <vector>             <string>com</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domorg</string>           <vector>             <string>org</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domus</string>           <vector>             <string>us</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>donutsgroup2</string>           <vector>             <string>fish</string>             <string>chat</string>             <string>associates</string>             <string>media</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>dotlove</string>           <vector>             <string>love</string>           </vector>         </entry>       </map>     </map-array>   </entry>   <entry>     <string>digicert</string>     <string-array/>   </entry> </hashtable> 

this code prints dombiz , biz can iterate.

    $myxmldata = "<hashtable>     <entry>     <string>domorder</string>     <map-array>       <map>         <entry>           <string>dombiz</string>           <vector>             <string>biz</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>dominfo</string>           <vector>             <string>info</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domcno</string>           <vector>             <string>com</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domorg</string>           <vector>             <string>org</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>domus</string>           <vector>             <string>us</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>donutsgroup2</string>           <vector>             <string>fish</string>             <string>chat</string>             <string>associates</string>             <string>media</string>           </vector>         </entry>       </map>       <map>         <entry>           <string>dotlove</string>           <vector>             <string>love</string>           </vector>         </entry>       </map>     </map-array>   </entry>   <entry>     <string>digicert</string>     <string-array/>   </entry> </hashtable>";  $xml = simplexml_load_string($myxmldata); $json = json_encode($xml); $tld = json_decode($json,true);  print($tld['entry'][0]['map-array']['map'][0]['entry']['string']); // dombiz print('<br />'); print($tld['entry'][0]['map-array']['map'][0]['entry']['vector']['string']); // biz 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -