pass URL special characters in XML to curl

Qvffmlqdqlfjo

New Member
I had an XML file with a url variable containing special characters such as &, = etcI have two questions:A. Since the special characters are not allowed in XML, how should I enter the URL? Should I encode the url and then put in XML file?B. Assuming that I encode the url and put it in XML file and then read in a php script. \[code\]$fxml = simplexml_load_file("mylist.xml");$fxml -> getName();foreach($fxml->children() as $mylist) { $url = $mylist -> url; $url = urldecode(url); echo $url; $feed = curl_init( $url ); curl_setopt($feed, CURLOPT_RETURNTRANSFER, 1); curl_setopt($feed, CURLOPT_HEADER, 0); $xml = simplexml_load_string(curl_exec($feed)); curl_close($feed); //--------------------- //--------------------- }\[/code\]Here is the sample XML file:\[code\]<?xml version="1.0" encoding="UTF-8"?> <feed> <mylist> <name> SISC </name> <url> http://epubs.siam.org/action/showFeed?ui=0&mi=3chvf9&ai=s0&jc=sjnaam&type=etoc&feed=rss </url> </mylist> </feed>\[/code\]Notice that I have replaced the URL in encoded form where original & is replaced by its code. I also tried not using urldecode but I only get echo $url correctly.If I copy paste the url in curl_init($url ) under single quotes, everthing works.But when I encode the url and put it in XML and decode back and put it in curl_init($url ), it does not work.When I echo the decoded $url (see above) then I get the correct url list displayed. What am I doing wrong ?I read closely related posts, but could not solve this.
 
Back
Top