Viewed   64 times

What are the recommended libraries for XML in PHP? Advantages? Looking to create/send/parse XML. Needs to support High Volume (Millions of calls per day)

 Answers

5

PHP supports a number of XML libraries.

If memory is an issue, for instance due to large files, use an Event-based parser over a tree-based one.Tree-based parsers must fully load the file into memory in order to parse the XML. Event-based parsers do not need to load the entire file into memory to begin parsing.

See this article about what's new with XML in PHP5 and a discussion of their pros and cons.

You might also reconsider where you store the data, since filesystem might be too slow for millions of calls. How about Xindice?

Tuesday, October 4, 2022
4

On some installations, there is a bug in pecl. Find this line;

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@" 

remove the -n

If you want to script it, try:

sed -i "$ s|-n||g" /usr/bin/pecl
Monday, October 24, 2022
1

If anyone should be interested, i have provided the correct answer:

$soapUrl = "http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint";

$xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/"><customerID>XXX</customerID><key>XXXXXX-XXXXXX</key><serviceID></serviceID><paramID>0</paramID><address>RiksvŠgen 5</address><postcode>59018</postcode><city>Mantorp</city><maxhits>10</maxhits></SearchCollectionPoint></soap12:Body></soap12:Envelope>';

$headers = array(
"POST /package/package_1.3/packageservices.asmx HTTP/1.1",
"Host: privpakservices.schenker.nu",
"Content-Type: application/soap+xml; charset=utf-8",
"Content-Length: ".strlen($xml_post_string)
); 

$url = $soapUrl;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch); 
curl_close($ch);

$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);

$parser = simplexml_load_string($response2);
Thursday, September 29, 2022
 
1

I use the serialized Java objects directly.

Thursday, November 10, 2022
 
1

You can output XML directly from SQL Server 2005 using

FOR XML    

The results of a query are returned as an XML document. Must be used with one of the three RAW, AUTO and EXPLICIT options

RAW

Each row in the result set is an XML element with a generic identifier as the element tag

AUTO    

Results returned in a simple nested XML tree. An element will be generated for each table field in the SELECT clause

EXPLICIT    

Specifies the shape of the resulting XML tree explicitly. A query must be written in a particular way so that additional information about the nesting is specified

XMLDATA

Returns the schema, but does not add the root element to the result

ELEMENTS    

Specifies that the columns are returned as child elements to the table element. If not specified, they are mapped as attributes

Generate an inline XSD schema at the same time using

XMLSCHEMA

You can handle null values in records using

XSINIL

You can also return data in Binary form.

You might want to have a look on MSDN for XML support in SQL Server 2005, for technologies such as XQuery, XML data type, etc.

Sunday, November 20, 2022
 
mihailo
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :