• Advertisement
Sign in to follow this  

TinyXML GetText()

This topic is 3033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I would like to ask, how to load more data with GetText() ? I am trying to load collada file and it contains 10000+ characters. it loads only first 256 letters. data are between

in <triangles>. Thank you.

Share this post


Link to post
Share on other sites
Advertisement

const char * INDICES_DATA = NULL;

POLYGONS = MESH->FirstChildElement("triangles");

if(POLYGONS)
{
P = POLYGONS->FirstChildElement("p");
INDICES_DATA = P->GetText();
}

INDICES_DATA contains string of numbers. Length of string is really 10000+ .

Thank you for reply


EDIT: it works, when i create array like char INDICES_DATA[50000];
but when i allocate it , it doesn't work, lol, strange

[Edited by - wh1sp3rik on November 4, 2009 6:46:36 AM]

Share this post


Link to post
Share on other sites
What are the types of POLYGONS and P?

Are you sure POLYGONS is non-null, i.e., that GetText is actually being called?

Share this post


Link to post
Share on other sites
Quote:
Original post by wh1sp3rik
EDIT: it works, when i create array like char INDICES_DATA[50000];
but when i allocate it , it doesn't work, lol, strange
What do you mean by "allocate it"? Can we see an example where it does and doesn't work?

Share this post


Link to post
Share on other sites
Have you read the caveat / limitation of GetText? Is all the text you want to retrieve in the <p> element and not delimited by another child element? (although a quick look at the COLLADA spec says it shouldn't be)

How are you determining that the length of the string is 256?

Quote:
EDIT: it works, when i create array like char INDICES_DATA[50000];
but when i allocate it , it doesn't work, lol, strange

I don't follow you here. GetText returns a const char *.. how are you putting it into that array?

Share this post


Link to post
Share on other sites
this works :)
char INDICES_DATA[500000];

int len=0;

POLYGONS = MESH->FirstChildElement("triangles");

if(POLYGONS)

{

P = POLYGONS->FirstChildElement("p");

len = UtilityManager::char_length(P->GetText());
memcpy(INDICES_DATA, P->GetText(), sizeof(char)*len);
}


LEN is 380650, yeah, pretty big collada model :D
by allocate it, i mean
char * INCIDES_DATA;

...

INDICES_DATA = new char[len];

...

this doesn't work, it will save only length about 256 letters.

Share this post


Link to post
Share on other sites
Can you post the exact code that doesn't work, when you try to dynamically allocate INDICES_DATA?

Share this post


Link to post
Share on other sites
I think you'll find the entire string has been loaded, it's just that MSVS only displays the first 256 bytes as a preview in the tooltip.

Share this post


Link to post
Share on other sites
mattd: Actually no. I have another function, which split string into numbers :) and it return only these numbers.

Share this post


Link to post
Share on other sites
Quote:
Original post by wh1sp3rik
mattd: Actually no. I have another function, which split string into numbers :) and it return only these numbers.
Can we see that function? What does strlen(INCIDES_DATA) return in both cases?

Share this post


Link to post
Share on other sites
Don't worry :) my length function works correctly.

i found a problem. Problem is, i can't get amount of float items :D it returned only 500 numbers .. because there were value with 0 :D and i tried to count until data = NULL :D i just forgot, It works only with chars.

Is there a way, how to calculate amount of floats in array ? :) which is dynamicly allocated ? float * variable = new float[1000]; ?

Share this post


Link to post
Share on other sites
Quote:
Original post by wh1sp3rik
Is there a way, how to calculate amount of floats in array ? :) which is dynamicly allocated ? float * variable = new float[1000]; ?

If you don't know the size you allocated with, then no. Use a std::vector or similar instead.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement