如何将数据从数据库列获取到XMl数据到Html页面或Php文件

时间:2014-11-26 09:19:45

标签: php xml xml-parsing xmlreader oci

您好我有一个名为CaseInfo的Sql Database表。 在该表内第三列包含Xml数据(巨大文件)。 我试图在PHP中获取数据和对象或任何内容,并希望将其显示到Html页面中。 我做了以下代码。 这是我希望第三列数据命名为EDITABLEL的函数。

function get_case_id_details($caseId) {
            //TODO: Get these variables from some secure location or config file


    write_log("ITAP :Inside get_case_id_details Method ...");
            $username='acleee';
            $password='acleee';
            $host='10.172.82.48';
            $port='1521';
            $db='example';

            $db_details=$host . ':' . $port . '/' . $db;

            $conn = oci_connect($username,$password, $db_details);

            if (!$conn){
                            return $caseId;
              }

            $sql = "SELECT * FROM CASEINFO_DATA WHERE id ='$Id'";

            $stmt = oci_parse($conn, $sql);


            oci_bind_by_name($stmt,":id",$Id,2);


            oci_execute($stmt);

            while (($row = oci_fetch_object($stmt)) != false) {
            //fetching that object and priting into log


                write_log("CASEID : ".$row->ID); 
                write_log("START_TIME : ".$row->START_TIME); 

                 //how can i get third column which has xml data into php or html page?

我尝试了从这里开始的方法

        // $xml_string =  .$row->EDITABLEL;
        //  write_log("ITAP: XML:  ".$xml_string);


        //var b=bool OCI-Lob::writeTemporary ( $xml_string [, int $lob_type = OCI_TEMP_CLOB ] );
        //write_log($b);
        // $file = "../wp-content/plugins/itap-functionality-plugins/sample.xml";
        // file_put_contents($file, $xml_string); 
        // var_dump($row->EDITABLE_INFO_SECTION);



        //echo "<pre>". htmlentities($xml_string) . "</pre>";


        //echo htmlentities($xml_string);

我尝试了以下方式结束。 然后我将其打印到HTML pAge

        $itap_html=" <table align=\"center\" style=\" width:70%; border:1px solid black; border-collapse: collapse; margin-left:15%;margin-top:10%; position:absolute;\" >
            <tr style=\"border:1px solid black;\">
            <th style=\"border:1px solid black;\">CASE ID</th>
            <th style=\"border:1px solid black;\">EDITABLE_INFO_SECTION</th> 
             </tr>
          <tr style=\"border:1px solid black;\">
            <td style=\"border:1px solid black; text-align: center;\">". $row->ID ."</td>
            <td style=\"border:1px solid black; text-align: center;\">". $row->EDITABLE."</td> 

          </tr>
        </table>";
    echo $itap_html;


    }

                return true;

}

1 个答案:

答案 0 :(得分:0)

得到了答案...... 需要在第一段代码后添加以下行...

//reading Big Xml File 
        $foo = $row->EDITABLE_INFO_SECTION->load(); 
        write_log("This is xml output".$foo);