2

I am trying to parse an .x3d document using RapidXml. Unfortunately, it only gives me the first 100 characters of any node attribute. I looked through the documentation, and it looks like there shouldn't be any limit on attribute value length.

I'm using RapidXml in Xcode; maybe the dynamic memory allocation doesn't work with the xcode compiler? has anyone else encountered this? Is there any way to overcome this limitation?

    myfile.open(location.c_str(), std::ifstream::in);
if (myfile.is_open())
{
    while ( myfile.good() )
    {
        getline (myfile,line);
        text += line;
    }
    myfile.close();
}
text += "\0";
rapidxml::xml_document<> doc; 
char *temp = new char[text.length() + 1];
strcpy(temp, text.c_str());
doc.parse<rapidxml::parse_no_data_nodes>(temp); 

//why doesnt this work?
rapidxml::xml_node<>* root = doc.first_node();
rapidxml::xml_node<> *indexedfaceset = getChild(root, "IndexedFaceSet");
rapidxml::xml_attribute<> *indices = indexedfaceset->first_attribute("coordIndex");
rapidxml::xml_node<> *coordinate = getChild(indexedfaceset, "Coordinate");;
rapidxml::xml_attribute<> *coords = coordinate->first_attribute("point");

std::string indices_string = indices->value(); //gets cut off
int isize = indices->value_size(); //this is 108, although the string is longer

    std::string coords_string = coords->value(); //gets cut off
int csize = indices->value_size(); //this is also 108, different size from indices

Thanks!

  • No idea - but the new/strcpy thing looks smelly : why not call `doc.parse` on `text.c_str()` directly (or, if you need a copy, just on a straight copy to another std::string? More importantly, where is `temp` deleted??? – Roddy Nov 30 '12 at 21:29

0 Answers0