| 1154 | |
| 1155 | |
| 1156 | const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) |
| 1157 | { |
| 1158 | TiXmlDocument* document = GetDocument(); |
| 1159 | |
| 1160 | // Read in text and elements in any order. |
| 1161 | const char* pWithWhiteSpace = p; |
| 1162 | p = SkipWhiteSpace( p, encoding ); |
| 1163 | |
| 1164 | while ( p && *p ) |
| 1165 | { |
| 1166 | if ( *p != '<' ) |
| 1167 | { |
| 1168 | // Take what we have, make a text element. |
| 1169 | TiXmlText* textNode = new TiXmlText( "" ); |
| 1170 | |
| 1171 | if ( !textNode ) |
| 1172 | { |
| 1173 | return 0; |
| 1174 | } |
| 1175 | |
| 1176 | if ( TiXmlBase::IsWhiteSpaceCondensed() ) |
| 1177 | { |
| 1178 | p = textNode->Parse( p, data, encoding ); |
| 1179 | } |
| 1180 | else |
| 1181 | { |
| 1182 | // Special case: we want to keep the white space |
| 1183 | // so that leading spaces aren't removed. |
| 1184 | p = textNode->Parse( pWithWhiteSpace, data, encoding ); |
| 1185 | } |
| 1186 | |
| 1187 | if ( !textNode->Blank() ) |
| 1188 | LinkEndChild( textNode ); |
| 1189 | else |
| 1190 | delete textNode; |
| 1191 | } |
| 1192 | else |
| 1193 | { |
| 1194 | // We hit a '<' |
| 1195 | // Have we hit a new element or an end tag? This could also be |
| 1196 | // a TiXmlText in the "CDATA" style. |
| 1197 | if ( StringEqual( p, "</", false, encoding ) ) |
| 1198 | { |
| 1199 | return p; |
| 1200 | } |
| 1201 | else |
| 1202 | { |
| 1203 | TiXmlNode* node = Identify( p, encoding ); |
| 1204 | if ( node ) |
| 1205 | { |
| 1206 | p = node->Parse( p, data, encoding ); |
| 1207 | LinkEndChild( node ); |
| 1208 | } |
| 1209 | else |
| 1210 | { |
| 1211 | return 0; |
| 1212 | } |
| 1213 | } |