Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:22:33+00:00 2026-06-17T21:22:33+00:00

I had an XML file with a url variable containing special characters such as

  • 0

I had an XML file with a url variable containing special characters such as &, = etc

I 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.

$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);
        //---------------------
        //---------------------
 }

Here is the sample XML file:

<?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>

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:22:34+00:00Added an answer on June 17, 2026 at 9:22 pm

    Let’s use & for the sake of example.

    If you want a & in the data of a URL (as opposed to indicating the start of a new query string key/pair). Then you need to URL encode it (as %26) before adding it to the URL.

    If you want a & in the data of an XML document (e.g. if the data is a URL with a query string) then you need to XML encode it (as &amp;). You should be constructing the XML with an XML library (and not string bashing or templating) and the library will take care of it for you.

    You should not have to urldecode data you take out of XML before using it as a URL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had xml file which have some data .and I had navigation url tage
recently I had an error, which was caused by a corrupted AndroidManifest.xml file. Is
Has anyone had this problem? My projects tend to have some long XML files
When i retrieve the XML file from URL, i can Parse all the elements
I have a csv file which I want to convert to xml but the
I am having a ajax call which parses the xml file. I have set
I have two WARS: base-overlay example-app base-overlay has XML config files in src/main/webapp/WEB-INF/spring/*.xml .
I want to parse an XML file from URL using JDOM. But when trying
I have this problem where all URLs like context/path/file/anything/that/follows becomes context/path/file.php/anything/that/follows or context/path/file.xml/anything/that/follows .
I have an xml document with a root element, two child elements, 'diagnostic' and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.