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

  • Home
  • SEARCH
  • 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 755555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:08:36+00:00 2026-05-14T15:08:36+00:00

RapidXML is a fast, lightweight C++ XML DOM Parser, but it has some quirks.

  • 0

RapidXML is a fast, lightweight C++ XML DOM Parser, but it has some quirks.

The worst of these to my mind is this:

3.2 Ownership Of Strings.

Nodes and attributes produced by RapidXml do not
own their name and value strings. They
merely hold the pointers to them. This
means you have to be careful when
setting these values manually, by
using xml_base::name(const Ch *) or
xml_base::value(const Ch *) functions.

Care must be taken to ensure that
lifetime of the string passed is at
least as long as lifetime of the
node/attribute. The easiest way to
achieve it is to allocate the string
from memory_pool owned by the
document. Use
memory_pool::allocate_string()
function for this purpose.

Now, I understand it’s done this way for speed, but this feels like an car crash waiting to happen. The following code looks innocuous but ‘name’ and ‘value’ are out of scope when foo returns, so the doc is undefined.

void foo()
{
  char name[]="Name";
  char value[]="Value";

  doc.append_node(doc.allocate_node(node_element, name, value));
}

The suggestion of using allocate_string() as per manual works, but it’s so easy to forget.

Has anyone ‘enhanced’ RapidXML to avoid this issue?

  • 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-14T15:08:36+00:00Added an answer on May 14, 2026 at 3:08 pm

    I don’t use RapidXML, but maybe my approach can solve your problem.

    I started using Xerces, but I found it heavy, besides other minor annoyances, so I moved to CPPDOM. When I made the move I decided to create a set of wrapper classes, so that my code wouldn’t be dependent from the specific XML ‘engine’ and I could port to another if needed.

    I created my own classes to represent the basic DOM entities (node, document, etc). Those classes use internally the pimpl idiom to use CPPDOM objects.
    Since my node object contains the ‘real’ node object (from CPPDOM) I can manage anything as needed, so proper allocation and deallocation of strings wouldn’t be a problem there.

    Since my code is for CPPDOM, I don’t think it would be much useful for you, but I can post it if you want.

    BTW, if you already have too much code that already uses RapidXML you can reproduce its interfaces in your wrapper classes. I didn’t do it because the code that used Xerces was not that long and I’d have to rewrite it anyway.

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

Sidebar

Related Questions

I know there are some very good Perl XML parsers like XML::Xerces , XML::Parser::Expat
I want a lite-weight C++ XML parser/DOM that: Can take UTF-8 as input, and
I've worked myself through the rapidXML sources and managed to read some values. Now
There are plenty of Libraries to parse XML, but it seems there aren't many
I just started using rapidXML since it was recommended to me. Right now to
How can I prevent RapidXML from adding tabs and newlines between element tags when
In my C++ program I want to parse a small piece of XML, insert
I'm trying to parse XML data stored in a variable, not a file. The
I need start off with code because I am not sure what terminology 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.