| 798 | |
| 799 | |
| 800 | const TCHAR* TiXmlElement::ReadValue( const TCHAR* p, TiXmlParsingData* data ) |
| 801 | { |
| 802 | TiXmlDocument* document = GetDocument(); |
| 803 | |
| 804 | // Read in text and elements in any order. |
| 805 | p = SkipWhiteSpace( p ); |
| 806 | while ( p && *p ) |
| 807 | { |
| 808 | if ( *p != '<' ) |
| 809 | { |
| 810 | // Take what we have, make a text element. |
| 811 | TiXmlText* textNode = new TiXmlText( TEXT("") ); |
| 812 | |
| 813 | if ( !textNode ) |
| 814 | { |
| 815 | if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0 ); |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | p = textNode->Parse( p, data ); |
| 820 | |
| 821 | if ( !textNode->Blank() ) |
| 822 | LinkEndChild( textNode ); |
| 823 | else |
| 824 | delete textNode; |
| 825 | } |
| 826 | else |
| 827 | { |
| 828 | // We hit a '<' |
| 829 | // Have we hit a new element or an end tag? |
| 830 | if ( StringEqual( p, TEXT("</"), false ) ) |
| 831 | { |
| 832 | return p; |
| 833 | } |
| 834 | else |
| 835 | { |
| 836 | TiXmlNode* node = Identify( p ); |
| 837 | if ( node ) |
| 838 | { |
| 839 | p = node->Parse( p, data ); |
| 840 | LinkEndChild( node ); |
| 841 | } |
| 842 | else |
| 843 | { |
| 844 | return 0; |
| 845 | } |
| 846 | } |
| 847 | } |
| 848 | p = SkipWhiteSpace( p ); |
| 849 | } |
| 850 | |
| 851 | if ( !p ) |
| 852 | { |
| 853 | if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0 ); |
| 854 | } |
| 855 | return p; |
| 856 | } |
| 857 | |