Reputation: 2157
I do query an oracle database for a field that stores xml content using blob data type
I want to generate a string to pass as parameter to a simplexml_load_string function.
I am receiving the resource type:
object(OCI-Lob)[111]
public 'descriptor' => resource(118, oci8 descriptor)
And using this code :
$query = "SELECT xmlcontent FROM myxmltable";
$stid = oci_parse($conn, $query);
oci_execute($stid);
$xml = '';
while (($row = oci_fetch_assoc($stid)) != false) {
// $xml = simplexml_load_string($row['XML']);
$xml = $row['xmlcontent'];
}
var_dump($xml);
How can i transform resource to a string ?
The XML i wanto to turn from object to string is :
<?xml version="1.0" encoding="utf-8"?>
<VehicleValidation xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Validation Id="Validation">
<Vehicle>
<Year>2017</Year>
<Brand>One car brand</Brand>
</Vehicle>
<Brand>
<Info>
<Data>
<Address>
One car brand Address
</Address>
<Data>
</Info>
</Brand>
</Validation>
</VehicleValidation>
Upvotes: 1
Views: 69
Reputation: 13004
OCI-Lob
is a class that provides various useful methods for interacting with the represented LOB content.
You can probably pass the result of the load
method directly into simplexml_load_string
:
$xml = simplexml_load_string($row['xmlcontent']->load());
Make sure to consider memory limitations as mentioned on the manual page:
As script execution is terminated when the memory_limit is reached, ensure that the LOB does not exceed this limit. In most cases it's recommended to use OCI-Lob::read instead.
Upvotes: 1