XML : display xml code in a table with php

I want it to display something like

concept type Relation type Code from XML file showing the nodes and child elements

I can get it to display in an array in the table but I don't know how to display it in xml format so it is easier to read.

my php file is

      <?php  #error_reporting(0);  #header("Content-type: text/xml");    $get = ('Human.cogxml');  $cogxml = simplexml_load_file($get);  $data = $cogxml->support->conceptTypes->ctype;  $datas = $cogxml->support->relationTypes->rtype;  ?>  <html>        <head>          <title>Hello World</title>      </head>      <body>          <table border="2">              <tr>                  <th>Concept Name</th>                  <th>Relation Type</th>                  <th>CoGui XML</th>              </tr>                <?php              foreach ($data as $row) {                  ?>                  <tr>                      <td>              <?php echo $row['label']; ?>                      </td>                      <?php                      foreach ($datas as $row2) {                          ?>                          <td>                      <?php echo $row2['label'];  ?>                          </td>                          <td>                              <?php                              header('Content-type text/xml');                              #dom->preserveWhiteSpace = false;                              $file = file_get_contents('http://data.fcc.gov/api/license-view/basicSearch/getLicenses?searchValue=Verizon+Wireless');                                 $movies = new SimpleXMLElement($file);                                 echo '<pre>';  print_r($movies);  echo '<pre>';                              # echo $dom->XML();                               ?>                          </td>                      </tr>                      <?php              }              }              ?>          </table>      </body>    </html>    

My xml file is

  <cogxml>      <namespace name="http://www.lirmm.fr/cogui#" prefix=""/>      <support name="vocabulary">          <conceptTypes>              <ctype id="http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841" label="Human" x="10" y="10">                  <translation descr="" label="Human" lang="en"/>              </ctype>              <ctype id="http://www.lirmm.fr/cogui#ct_ef8dc30a-fc37-48fa-80f3-4588e4d101d2" label="Adult" x="120" y="10">                  <translation descr="" label="Adult" lang="en"/>              </ctype>              <ctype id="http://www.lirmm.fr/cogui#ct_1b5b2797-a707-4758-a200-6e9bef2f13b9" label="Female" x="90" y="110">                  <translation descr="" label="Female" lang="en"/>              </ctype>              <ctype id="http://www.lirmm.fr/cogui#ct_be05db54-5043-488c-a08b-3bb643cf0f78" label="Child" x="130" y="60">                  <translation descr="" label="Child" lang="en"/>              </ctype>              <ctype id="http://www.lirmm.fr/cogui#ct_8a7f45ec-0204-4c73-921b-781d87327ba0" label="Girl" x="170" y="220">                  <translation descr="" label="Girl" lang="en"/>              </ctype>                  <ctype id="http://www.lirmm.fr/cogui#ct_199f3367-213f-4139-8ad4-fe2f4e4874e7" label="Woman" x="235" y="130">                  <translation descr="" label="Woman" lang="en"/>              </ctype>              <order id1="http://www.lirmm.fr/cogui#ct_ef8dc30a-fc37-48fa-80f3-4588e4d101d2" id2="http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841"/>              <order id1="http://www.lirmm.fr/cogui#ct_1b5b2797-a707-4758-a200-6e9bef2f13b9" id2="http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841"/>              <order id1="http://www.lirmm.fr/cogui#ct_be05db54-5043-488c-a08b-3bb643cf0f78" id2="http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841"/>              <order id1="http://www.lirmm.fr/cogui#ct_8a7f45ec-0204-4c73-921b-781d87327ba0" id2="http://www.lirmm.fr/cogui#ct_1b5b2797-a707-4758-a200-6e9bef2f13b9"/>              <order id1="http://www.lirmm.fr/cogui#ct_199f3367-213f-4139-8ad4-fe2f4e4874e7" id2="http://www.lirmm.fr/cogui#ct_1b5b2797-a707-4758-a200-6e9bef2f13b9"/>              <order id1="http://www.lirmm.fr/cogui#ct_8a7f45ec-0204-4c73-921b-781d87327ba0" id2="http://www.lirmm.fr/cogui#ct_be05db54-5043-488c-a08b-3bb643cf0f78"/>              <order id1="http://www.lirmm.fr/cogui#ct_199f3367-213f-4139-8ad4-fe2f4e4874e7" id2="http://www.lirmm.fr/cogui#ct_ef8dc30a-fc37-48fa-80f3-4588e4d101d2"/>          </conceptTypes>          <relationTypes>              <rtype id="http://www.lirmm.fr/cogui#_rt_336363f1-0068-48d1-b1de-93ae264e4f49" idSignature="http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841 http://www.lirmm.fr/cogui#_ct_5f3287f9-fb7b-47c2-84b0-e25694b29841" label="Link">                  <translation descr="" label="Link" lang="en"/>              </rtype>           </relationTypes>          <nestingTypes>              <ntype id="http://www.lirmm.fr/cogui#_nt_23d8104c-fbe5-4228-895f-074faa673d74" label="Nesting">                  <translation descr="" label="Nesting" lang="en"/>              </ntype>          </nestingTypes>          <conformity/>          <modules/>      </support>      <localeTypes name="undefined_vocabulary">          <conceptTypes/>          <relationTypes/>          <nestingTypes/>          <conformity/>          <modules/>      </localeTypes>      <graph id="_g1" label="_g1" nature="fact" set="default_set"/>  </cogxml>    

No comments:

Post a Comment