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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:35:11+00:00 2026-05-31T22:35:11+00:00

I search the web alot and didn’t find c++ function that replace xml Special

  • 0

I search the web alot and didn’t find c++ function that replace xml Special Character with their escape sequence?
Is there something like this?

I know about the following:

Special Character   Escape Sequence Purpose  
&                   &           Ampersand sign 
'                   '          Single quote 
"                   "          Double quote
>                   >            Greater than 
<                   &lt;            Less than

is there more? what about writing hexadecimal value like 0×00,
Is this also a problem?

  • 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-31T22:35:12+00:00Added an answer on May 31, 2026 at 10:35 pm

    As has been stated, it would be possible to write your own. For example:

    #include <iostream>
    #include <string>
    #include <map>
    
    int main()
    {
        std::string xml("a < > & ' \" string");
        std::cout << xml << "\n";
    
        // Characters to be transformed.
        //
        std::map<char, std::string> transformations;
        transformations['&']  = std::string("&amp;");
        transformations['\''] = std::string("&apos;");
        transformations['"']  = std::string("&quot;");
        transformations['>']  = std::string("&gt;");
        transformations['<']  = std::string("&lt;");
    
        // Build list of characters to be searched for.
        //
        std::string reserved_chars;
        for (auto ti = transformations.begin(); ti != transformations.end(); ti++)
        {
            reserved_chars += ti->first;
        }
    
        size_t pos = 0;
        while (std::string::npos != (pos = xml.find_first_of(reserved_chars, pos)))
        {
            xml.replace(pos, 1, transformations[xml[pos]]);
            pos++;
        }
    
        std::cout << xml << "\n";
    
        return 0;
    }
    

    Output:

    a < > & ' " string
    a &lt; &gt; &amp; &apos; &quot; string
    

    Add an entry into transformations to introduce new transformations.

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

Sidebar

Related Questions

I search the web alot and didn't find js function that replace xml Special
Are there any web search APIs or search engines that allow automated queries?
I am running an ASP.NET web application that connects to the WSS 3.0 search
i search alot for this but can't find an aswer... I have made a
I search the web a lot when writing code. When working in Visual Studio
Search the web for the phrase I cosay. I run across this phrase being
I need to add full web search to my site. I need something like
I've been using Google Web Search API but the searched keyword is coming highlighted
I'm building a small web search engine for searching about 1 million web pages
Could you share your frequently used tricks to search the web for programming related

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.