form 1.From this XML: @verbatim
<foo>This is <b>text</b></foo>
@endverbatim
GetText() will return "This is ".
form 2.From this XML: @verbatim
<foo>This is <b color="255,255,0">colorful</b> text</foo>
@endverbatim
TinyXml return 3 element: "This is ", "colorful" and " text".
form 3.From this XML: @verbatim
<foo>This is <b color="255,255,0">colorful</b> text</foo>
@endverbatim
TinyXml only return 2 element: "This is " and "colorful".
I wish to support form 3 in my application. I write code like this:
for (elem = elem->FirstChildElement(); elem; elem = elem->NextSiblingElement())
{
if (elem->GetText())
printf("%s\n", elem->GetText());
for (elem1 = elem->FirstChildElement(); elem1; elem1 = elem1->NextSiblingElement())
{
if (elem1->GetText())
printf("%s\n", elem1->GetText());
}
}
The output is:
This is
colorful
Is my code correct?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, but I see no difference between form 2 and form 3...
Anyway, being the XML structure as follows:
<ELEMENT "foo">
....<TEXT "This is ">
....<ELEMENT "b">
........<TEXT "colorful">
....<TEXT " text">
there is no way to get 3rd text node content using GetText(). You have to change your approach (perhaps a recursive function is a better choice).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
form 1.From this XML:
@verbatim
<foo>This is <b>text</b></foo>
@endverbatim
GetText() will return "This is ".
form 2.From this XML:
@verbatim
<foo>This is <b color="255,255,0">colorful</b> text</foo>
@endverbatim
TinyXml return 3 element: "This is ", "colorful" and " text".
form 3.From this XML:
@verbatim
<foo>This is <b color="255,255,0">colorful</b> text</foo>
@endverbatim
TinyXml only return 2 element: "This is " and "colorful".
I wish to support form 3 in my application. I write code like this:
for (elem = elem->FirstChildElement(); elem; elem = elem->NextSiblingElement())
{
if (elem->GetText())
printf("%s\n", elem->GetText());
for (elem1 = elem->FirstChildElement(); elem1; elem1 = elem1->NextSiblingElement())
{
if (elem1->GetText())
printf("%s\n", elem1->GetText());
}
}
The output is:
This is
colorful
Is my code correct?
Sorry, but I see no difference between form 2 and form 3...
Anyway, being the XML structure as follows:
<ELEMENT "foo">
....<TEXT "This is ">
....<ELEMENT "b">
........<TEXT "colorful">
....<TEXT " text">
there is no way to get 3rd text node content using GetText(). You have to change your approach (perhaps a recursive function is a better choice).