| 1169 | } |
| 1170 | |
| 1171 | const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXmlEncoding encoding) |
| 1172 | { |
| 1173 | TiXmlDocument* document = GetDocument(); |
| 1174 | |
| 1175 | // Read in text and elements in any order. |
| 1176 | const char* pWithWhiteSpace = p; |
| 1177 | p = SkipWhiteSpace(p, encoding); |
| 1178 | |
| 1179 | while (p && *p) |
| 1180 | { |
| 1181 | if (*p != '<') |
| 1182 | { |
| 1183 | // Take what we have, make a text element. |
| 1184 | TiXmlText* textNode = xr_new<TiXmlText>(""); |
| 1185 | |
| 1186 | if (!textNode) |
| 1187 | { |
| 1188 | if (document) |
| 1189 | document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding); |
| 1190 | return 0; |
| 1191 | } |
| 1192 | |
| 1193 | if (TiXmlBase::IsWhiteSpaceCondensed()) |
| 1194 | { |
| 1195 | p = textNode->Parse(p, data, encoding); |
| 1196 | } |
| 1197 | else |
| 1198 | { |
| 1199 | // Special case: we want to keep the white space |
| 1200 | // so that leading spaces aren't removed. |
| 1201 | p = textNode->Parse(pWithWhiteSpace, data, encoding); |
| 1202 | } |
| 1203 | |
| 1204 | if (!textNode->Blank()) |
| 1205 | LinkEndChild(textNode); |
| 1206 | else |
| 1207 | xr_delete(textNode); |
| 1208 | } |
| 1209 | else |
| 1210 | { |
| 1211 | // We hit a '<' |
| 1212 | // Have we hit a new element or an end tag? This could also be |
| 1213 | // a TiXmlText in the "CDATA" style. |
| 1214 | if (StringEqual(p, "</", false, encoding)) |
| 1215 | { |
| 1216 | return p; |
| 1217 | } |
| 1218 | else |
| 1219 | { |
| 1220 | TiXmlNode* node = Identify(p, encoding); |
| 1221 | if (node) |
| 1222 | { |
| 1223 | p = node->Parse(p, data, encoding); |
| 1224 | LinkEndChild(node); |
| 1225 | } |
| 1226 | else |
| 1227 | { |
| 1228 | return 0; |