| 1044 | // ---------------------------------------------------------------------------------------- |
| 1045 | |
| 1046 | int xml_parser:: |
| 1047 | parse_element ( |
| 1048 | const std::string& token, |
| 1049 | std::string& name, |
| 1050 | attrib_list& atts |
| 1051 | ) |
| 1052 | { |
| 1053 | name.erase(); |
| 1054 | atts.list.clear(); |
| 1055 | |
| 1056 | // there must be at least one character between the <> |
| 1057 | if (token[1] == '>') |
| 1058 | return -1; |
| 1059 | |
| 1060 | std::string::size_type i; |
| 1061 | std::istream::int_type ch = token[1]; |
| 1062 | i = 2; |
| 1063 | |
| 1064 | // fill out name. the name can not contain any of the following characters |
| 1065 | while ( (ch != '>') && |
| 1066 | (ch != ' ') && |
| 1067 | (ch != '=') && |
| 1068 | (ch != '/') && |
| 1069 | (ch != '\t') && |
| 1070 | (ch != '\r') && |
| 1071 | (ch != '\n') |
| 1072 | ) |
| 1073 | { |
| 1074 | name += ch; |
| 1075 | ch = token[i]; |
| 1076 | ++i; |
| 1077 | } |
| 1078 | |
| 1079 | // skip any whitespaces |
| 1080 | while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ) |
| 1081 | { |
| 1082 | ch = token[i]; |
| 1083 | ++i; |
| 1084 | } |
| 1085 | |
| 1086 | // find any attributes |
| 1087 | while (ch != '>' && ch != '/') |
| 1088 | { |
| 1089 | std::string attribute_name; |
| 1090 | std::string attribute_value; |
| 1091 | |
| 1092 | // fill out attribute_name |
| 1093 | while ( (ch != '=') && |
| 1094 | (ch != ' ') && |
| 1095 | (ch != '\t') && |
| 1096 | (ch != '\r') && |
| 1097 | (ch != '\n') && |
| 1098 | (ch != '>') |
| 1099 | ) |
| 1100 | { |
| 1101 | attribute_name += ch; |
| 1102 | ch = token[i]; |
| 1103 | ++i; |