Questions tagged [rapidxml]

A general purpose XML parser for C++ designed for execution speed and practical usage. It can also modify nodes and output a full xml document.

Rapidxml is a header-only XML parser with high usability, portability, and very good W3C compatibility.

  • no dependencies (except standard C++ library <cassert>, <cstdlib>, <new>, and <exception>
  • character type agnostic: supports narrow and wide, wchar_t UTF-16 and UTF-32, and UTF-8 if endianness is native
  • special memory pool object management for speed
  • not fully W3C compliant: ignores DOCTYPE declarations, and minor incompatibilities
  • robust and has a large unit test harness
  • easy to learn and use: begin writing useful parsing code in less than five minutes
  • license is Boost Software License or MIT License
  • stable since 2006
  • an additional header-only file adds the ability to stream out and format an xml document
  • other header classes simplify iterating through a document, loading from a file, and get child counts

Rapidxml is widely cross-platform compatible, its execution speed is proportional to the length of the XML data parsed, and it requires no configuration and no metadata or schema.

177 questions
21
votes
3 answers

RapidXML print header has undefined methods

I've been messing with using RapidXML on one of my projects. It was all going so well until I decided to use it for writing out xml. My code is more or less as follows: //attempt to open the file for writing std::ofstream file(fileName.c_str()); if…
Los Frijoles
  • 4,501
  • 3
  • 27
  • 46
20
votes
4 answers

How to parse an XML file with RapidXml

I have to parse an XML file in C++. I was researching and found the RapidXml library for this. I have doubts about doc.parse<0>(xml). Can xml be an .xml file or does it need to be a string or char *? If I can only use string or char * then I guess…
ashd
  • 201
  • 1
  • 2
  • 4
13
votes
8 answers

C++: How to extract a string from RapidXml

In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a std::string). RapidXml has been recommended to me, but I can't see how to retrieve the XML back as a text string. (I could iterate…
hamishmcn
  • 7,333
  • 10
  • 38
  • 45
8
votes
3 answers

rapidxml: how to iterate through nodes? Leaves out last sibling

Using rapidxml I'm wanting to loop through a set of nodes, and am using what I found to be the best way to do this (from trusty stackoverflow, the doc doesn't appear to have an example of iteration): while (curNode->next_sibling() !=NULL ) { …
Pete 2233
  • 176
  • 1
  • 1
  • 5
7
votes
1 answer

How to fix RapidXML String ownership concerns?

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…
Roddy
  • 63,052
  • 38
  • 156
  • 264
6
votes
3 answers

c++ rapidxml node_iterator example?

I just started using rapidXML since it was recommended to me. Right now to iterate over multiple siblings i do this: //get the first texture node xml_node<>* texNode = rootNode->first_node("Texture"); if(texNode != 0){ string test =…
user240137
  • 663
  • 3
  • 9
  • 15
5
votes
4 answers

Strange code breaks build in MSVC. What does it mean?

I am trying to include rapidxml into my current project. However, it would not build. Visual Studio would complain about this piece of code (rapidxml.hpp:419+451): 419: void *memory = allocate_aligned(sizeof(xml_attribute)); 420:…
bastibe
  • 14,886
  • 24
  • 86
  • 118
5
votes
2 answers

C++ RapidXML - Edit values in the XML file

I recently started using RapidXML, and parsing the values is fine (I can get the data from inside the elements), but I want to edit the values inside of the elements. For the purposes of this program, I want to turn this:
user569322
4
votes
1 answer

RapidXML giving empty CDATA nodes

I wrote the code bellow to get CDATA node value too, I got the node's name, but the values are in blank. I changed the parse Flags to parse_full, but it not worked too. If I manually remove "" from the XML, It gives the value as…
Roger Russel
  • 714
  • 7
  • 17
4
votes
2 answers

RapidXML compilation error parsing string

I have been having some trouble using RapidXML to parse a string. I receive an error from within Eclipse claiming the parse function does not exist. make all Building file: ../search.cpp Invoking: Cross G++ Compiler g++ -DDEBUG -O0 -g3 -Wall -c…
stephenwebber
  • 633
  • 4
  • 15
3
votes
1 answer

How to insert a new node in a xml_document using RapidXml for C++ using strings?

std::string src = "aaabbbccc"; std::string src2 = "xxx"; I want to append the node in src2 inside the tree in src using RapidXml I do this: xml_document<> xmldoc; xml_document<>…
Andry
  • 14,281
  • 23
  • 124
  • 216
3
votes
1 answer

Is RapidXml thread safe?

The documentation for RapidXml says Pool maintains RAPIDXML_STATIC_POOL_SIZE bytes of statically allocated memory. Until static memory is exhausted, no dynamic memory allocations are done. When static memory is exhausted, pool allocates…
Tobias Furuholm
  • 4,447
  • 3
  • 28
  • 39
3
votes
2 answers

rapidxml throws exception on wchar_t content

When parsing wchar_t content on win32 platform, rapidxml may throw parse_error exception. The content: Here is my testing code: /* * @file : TestRapidXmlBug.cpp * @author: shilyx * @date : 2015-09-16 11:02:22.886 * @note…
shilyx
  • 98
  • 5
3
votes
1 answer

How do I handle RapidXml errors?

RapidXml throws an exception in case of an invalid XML file. Is it possible to recover from such a failure? For example, is it possible to check if the XML is valid beforehand, or recover and continue on? It seems that when such failures happen,…
ransh
  • 1,281
  • 4
  • 20
  • 45
3
votes
1 answer

moving (not copying) nodes using pugixml and rapidxml

I am looking for an XML library that supports a DOM interface. Performance is important for me so I was currently looking at rapidxml and also pugixml. The thing is that my application needs to modify the DOM tree, including moving nodes. And I…
user1192525
  • 657
  • 4
  • 18
1
2 3
11 12