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 6867189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:16:42+00:00 2026-05-27T03:16:42+00:00

I have a system that writes a XML file. The problem is that I

  • 0

I have a system that writes a XML file.

The problem is that I cannot have in the XML file this symbol &

I need to replace this symbol wherever it is find in the code with &

The problem is I have a LOT of strings, and I do not want to apply a function that will replace that symbol for EVERY SINGLE string I have.

This is an example:

$stringData ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$stringData .="<ingrooves_import xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:schemaLocation=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\" schema_version=\"1\" schema_revision=\"0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\">\n";
$stringData .= "<album>\n";
$stringData .= "<title>".$albumTitle."</title>\n";
$stringData .= "<label_reference>LA0001</label_reference>\n";
$stringData .= "<performer>".$MainArtist."</performer>\n";
$stringData .= "<catalog_number>".$CatalogueNumber."</catalog_number>\n";
$stringData .= "<upc>".$UPC_EAN_JAN."</upc>\n";
$stringData .= "<release_date>".$releaseDate."</release_date>\n";
$stringData .= "<copyright>".$DigiDistYear."</copyright>\n";

And I have many more of $stringData in my code. So you can understand I do not want to apply for every $stringData a code that will replace that symbol.

I want to find a way to tell to the code, that for any $stringData variable, and for any content this $stringData will encounter, then it must replace & with &amp;

Is there a way of doing it?

In few words, the code should do so:

For every content you are going to encounter inside the variable $stringData, from now on, you should change & with &amp; everytime you encounter this symbol.

Please help me!

Thanks

  • 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-05-27T03:16:43+00:00Added an answer on May 27, 2026 at 3:16 am

    At the end of the script, when you finished adding code to the string, add the following:

    $stringData = str_replace ('&','&amp;',$stringData);
    

    You can do also with regular expressions but this will work aswell 🙂

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

Sidebar

Related Questions

I have a DataTable that I'm creating an XML file from using .WriteXML(..), although
We have a web service that acccepts an XML file for any faults that
I have an System.IO.Stream object that may or may not be XML. What is
i want to have a xml file in the user specifed directory. for that
We have system here that uses Java JNI to call a function in a
I have a system that combines the best and worst of Java and PHP.
I have a system that uses a meta refresh to a logout page, which
I have a system that creates an order and that order can be billed
We have a system that has a Mysql database with about 2Gigs of data.
I have a system that compares fiscal year up to the current date to

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.