Re: [PHP] SimpleXMLElement is not Simple



just curious, what database are you using?

-nathan

On 9/27/07, Jeffery Fernandez <jeffery@xxxxxxxxxx> wrote:

I am having nightmares with this bit off code.

The following code work perfectly fine:

$soap_request_string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope";
xmlns:ns1="urn:Gateway_Proxy" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
http://www.w3.org/2003/05/soap-encoding";>
<env:Body>
<ns1:make_proxy_payment env:encodingStyle="
http://www.w3.org/2003/05/soap-encoding";>
<payment_id>61ecc268-1cd0-f468</payment_id>
<payment_amount>15495</payment_amount>

<callback_query_string>&amp;payment_id=61ecc268-1cd0-f468</callback_query_string>
<transaction_note>Order from Student Library Fees with Payment Id:
61ecc268-1cd0-f468</transaction_note>
</ns1:make_proxy_payment>
</env:Body>
</env:Envelope>
XML;

$xml = new SimpleXMLElement($soap_request_string, NULL, false, '
http://www.w3.org/2003/05/soap-envelope');
print_r($xml);
$ns = $xml->getNamespaces(true);
//print_r($ns);

foreach ($xml->children($ns['env']) as $body)
{
//printf("%s<br />", $body->getName());

foreach ($body->children($ns['ns1']) as $function)
{
printf("function %s()<br />", $function->getName());

foreach ($function->children() as $parameters)
{
printf("%s => \"%s\"<br />", $parameters->getName(),
$parameters);
}
}
}


However when the XML string is coming from the database it does not work.
The Field and table have a collation of "utf8_unicode_ci"

$soap_request_string = trim(str_replace(array("\n"), '',
$record['SoapRequestEnvelope']));
$xml = new SimpleXMLElement($soap_request_string, NULL, false, '
http://www.w3.org/2003/05/soap-envelope');
print_r($xml);


The above code is supposed to print out the following (for me to proceed
further):

SimpleXMLElement Object
(
[Body] => SimpleXMLElement Object
(
)
)


but only returns:
SimpleXMLElement Object
(
)


The XL string from the database looks exactly like this (after replacing
new lines):

<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="
http://www.w3.org/2003/05/soap-envelope"; xmlns:ns1="urn:Gateway_Proxy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xmlns:enc="
http://www.w3.org/2003/05/soap-encoding";><env:Body><ns1:make_proxy_payment
env:encodingStyle="http://www.w3.org/2003/05/soap-encoding";><payment_id>5ce30dcc-7df7-04e8</payment_id><payment_amount>10</payment_amount><callback_query_string>&amp;payment_id=5ce30dcc-7df7-04e8</callback_query_string><transaction_note>Order
from Student Library Fees with Payment Id:
5ce30dcc-7df7-04e8</transaction_note></ns1:make_proxy_payment></env:Body></env:Envelope>


I can't figure out whats wrong with the code. Any suggestions?

cheers,
Jeffery
--
Internet Vision Technologies
Level 1, 520 Dorset Road
Croydon
Victoria - 3136
Australia




Relevant Pages

  • Re: DISCOVER_XML_METADATA
    ... expansion of ASSL XML returned by the server. ... You could do ExpandObject for the server in step 1. ... you could request ExpandObject for that database -- this is step ... all cubes and nothing else. ...
    (microsoft.public.sqlserver.olap)
  • Re: Preservation of namespace prefixes in XML datatype
    ... representation well beyond merely preserving the logical meaning. ... > Now the ANSI/ISO SQL-2003 standard makes it pretty clear that the XML ... all the guarantee the database gives you is that we preserve the ... >> makes changes in namespace prefixes, will I the user/developer have the ...
    (microsoft.public.sqlserver.xml)
  • Re: Wanted:MAIL.MAI structure definition
    ... a relational database is more flexible in the retrival of data. ... Perhaps this impact has been softened as hardware has gotten faster, but, overhead is overhead, and if you weren't using the advances in hardware for overhead, those designs that have less overhead would also gain from the faster hardware. ... RFC822 header because your XML parser wouldn't be able to understand new ...
    (comp.os.vms)
  • Re: Rework [Was: Static vs. Dynamic typing...]
    ... Agile projects have an extraordinarily low chance of a big change. ... Suppose you start with XML files, and by Iteration 6 the ... Switching to a database is now cheaper than morphing XML files into a ...
    (comp.programming)
  • Re: Data source options
    ... > customer to access the app and own the data. ... and by keeping the "main database" closer to the "web application ... I've been watching the "maturation" of the XML space. ... Visage ISN'T free - but it is cheap as chips ...
    (comp.databases.pick)