Built in XML Parser?

Jaxel

Well-known member
Does XF have a built in XML parser like VB?

Or does it use PHP's built in SimpleXML?
 
I've seen it use SimpleXML somewhere. I can't remember which file exactly, but I believe they use SimpleXML.
 
Okay... I completely confused on how Zend_Http_Client...Basically I want to have an URL, and store the source of that URL into a string. In vBulletin I would have used their built in vURL function as follows:
Code:
	$vurl = new vB_vURL($vbulletin);
	$vurl->set_option(VURL_URL, 'http://www.xenforo.com/');
	$vurl->set_option(VURL_RETURNTRANSFER, 1);
	$vurl->set_option(VURL_FOLLOWLOCATION, 1);
	$vurl->set_option(VURL_TIMEOUT, 30);
	$result = $vurl->exec();

I'm trying to do the same thing with Zend_Http_Client...
Code:
	$client = new Zend_Http_Client('http://www.xenforo.com/');
	$result = $client->request();
	echo $result;

This should theoretically print out the source coode of the XenForo home page... instead it prints out:
Code:
HTTP/1.1 200 OK Date: Sun, 07 Nov 2010 02:47:18 GMT Server: Apache Last-modified: Sun, 07 Nov 2010 02:47:18 GMT Content-encoding: gzip Vary: Accept-Encoding Content-length: 2317 Connection: close Content-type: text/html; charset=UTF-8 ‹¥XýrÛ¸ÿ[z „Ÿœ)MÊŽ:Ž¤Œò5½\œ¤µ¯×L&£Hˆ¤MZf3÷@÷}²þ ))qr;gb’‹Å~þ°»ðäÞó·Ï.ß¿{ÁRSä³á„,‹§Þ¿EùR*é±(çZO½wõ2Ï"XgÃÁ¤†³(åJ3õj³:8õXH+K®K•XM½Ô˜ê,oE¹‚´ ’Eè˜Àf2“‹Y«ˆ°g²¨DžgeÂÀWÔef†muÁ´\™5WbºMúJÉJ(ÓL=™œé̈EÉ£eiD	³z7È0÷o ×L‰|êiÓäB§B™¦Sψ[FZ{­ýx ª´z‚ç´u‡I…_ÙxüÀ‹ê±•2=´ïñôðèôožœŽÚhüQuY‹ÛßWÀ††ŽTV™m®ø wTäl0¹wp0ÜpÅ	ÿĦìÇÑy›G‘¬K3òÙèçùÁáøôäääèÁÁñè£ÏÀa®ßñDÜdb=úøññppoU—‘Éd¹ûÌÜ>Vp©q)Áx‘‹áß7÷}¬´]J„iéúisÉ“7È8>Œ?>FfIÀuSF`5ªÐŠVô½?"é³›’Š\Fœ|##™³'¬åC­ó;sßÀÝz½Ýge£ ‘2ÉÅ/yÞ˜,ÒŠ	®ôˆt!Ë€WiÞÈXY©ª§‰û‰Ïô}°ü:ìÇ2ªÉ1„ËÅvD+axp@1^¿›·¦Þ•¯>ÕB5íãà08Ž‚"+aÓ“ÅÍtŸŠG–ÇÞl#ùºÃ§dž×ÕŸ—ÞÊëõ·Í‡“ÐÕ‹ÉRÆÍßô))Înl©q‚©£µ§î~Éb“ZóÖÂ3wÀ7›¨få2‘ˆoÏ®]D.*^RéƒIV$.îø‡±Xñ:7áíŠ*HHR‚ªL<Æó/+’Ì!ÆXQ„ÛIÉíÇ@$#ðÙ*γÎb-rox³¿Ëä噳l³c‹³ªª¬¡7{Z7ÿdž¨Ö¢•ÆŽgÝûî>””ÁM¨t]URl¸po=»…6¼Üæ¾£¨÷›tvÅ»Ba %ú=]¼Ú ö±´hØJpŸylÙÊvê±HyíãŒò#Ê‹TÄïwÒŒ# ^ Þàªú"ÙìÂ.2+	=m=ƒIz8›SƒúºW‰[4£L”‘ûC‘Iz4û±4uf²°e<Ø‹2á	Z]À^rmÖ6*¶T jÆÙJ¡31Y›\Êkf䝐4õ D꼋²6F–Ú¡+T-ëæ©]¼^î¨d½5oäºõ};—tˆ6BûÔ%ú{8öD¾’YÉL*¨û»–§ÂIX[ø?íáë^z u…eØ㥝úÆvT Ë·ÁöåÊØlõÀÑa‡Ñ­t†¾ÁY{Lˆ?탺®ã5¢¨r4ÆŽxP79[¡mÖJËÌ&\WŠõ“¦F>­Jßm‡‚f#—|ui|ÆÍóÐ7Ü~A^`œF2:çßËšE/ Ó”‘f:ÃQ€I“ÐØÊD¨­,;ŠÍYWø4j§Kn‰¸¤`B$[Õ fw¢(vJÖI ƒfyTxŠ‘íô¬»-0gFª€½‘°#†1Ö ‡#‰jîuÉuuÇ•”¶;ahÓn4pNáG°á	ëGª <¢~JoUPTí¶|Ù:a¹bÑ–W<:®¾¶ÙMÃÉJ"­ G»L9âŸ(k[õ²jT–¤èžÿýíh|8îÒÆ^›x×t2w»|YÃ^ãbÕµëù>&2²í)wÌW»á_0‰d‰½Kx³KYíèî9‚ÿw§dv)~4ǽ™®`Wÿ ‰?°ÀŒ÷é¢ãw1ö‡Ÿ‡”ñ¡.³Büˆó™»]•r}Æp­|4~t:~pJW*#cÞ´ÄÓÓñxÜŸó×P¢¤Òñ"sÞè3æzDæeVX·/*¨s̾ÊŒP=ƒt;€ÝU–´VYÑúxD4íöa¡£<‹Š¡ûó¦ZOº‡î.Œ>Itû­NŒ„
 
Zend_Http_Client::request() returns an object of type Zend_Http_Response.
Call the getBody() method on that object to fetch the actual html source of the requested page.

PHP:
$client = new Zend_Http_Client('http://www.xenforo.com/');
$result = $client->request();

// Get the response (minus headers)
$source = $result->getBody();

// Display the page as-is. (Or encode the special characters to display the source)
echo $source;
 
That worked... is there a reason to use Zend_Http_Client over something like file_get_contents() ?
 
Zend_Http_Client gives you a very fine grained control of how the actual request to your resource is made; including but not limited to the support of various http request methods, headers, cookies & http authentication. And since the result is in the form of Zend_Http_Response, it exposes you to a nice set of convenience methods for checking the response data like status codes, response headers, etc.

» Zend_Http_Client - Advanced Usage
http://framework.zend.com/manual/en/zend.http.client.advanced.html

» Various connection adapters available...
http://framework.zend.com/manual/en/zend.http.client.adapters.html

» Zend_Http_Response
http://framework.zend.com/manual/en/zend.http.response.html
 
Top Bottom