/*********************************************************************/ public void ProcessAttributes(string strAttributes) { strAttributes = TextNode.Normalize(strAttributes).Trim(); if (strAttributes == "") { return; } string strName = ""; string strValue = ""; bool bHaveQuote = false; bool bSingleQuote = false; AttributeState eState = AttributeState.Nothing; foreach (char chFind in strAttributes) { switch (chFind) { case ' ': { switch (eState) { // Found whitespace case AttributeState.Name: eState = AttributeState.AfterName; break; case AttributeState.InValue: { if (bHaveQuote) { strValue += " "; } else { AddAttribute(strName, strValue); strName = ""; strValue = ""; eState = AttributeState.Nothing; } break; } // Ignore white space here case AttributeState.Nothing: case AttributeState.StartValue: case AttributeState.AfterName: default: break; } break; } case '=': { switch (eState) { case AttributeState.Name: case AttributeState.AfterName: eState = AttributeState.StartValue; break; case AttributeState.InValue: { if (bHaveQuote) { strValue += "+"; } break; } default: // ??? this is bad??? Ignore for now! break; } break; } case '\'': { switch (eState) { case AttributeState.StartValue: eState = AttributeState.InValue; bHaveQuote = true; bSingleQuote = true; break; case AttributeState.InValue: { if (bHaveQuote && !bSingleQuote) { strValue += "\'"; } else if (bHaveQuote && bSingleQuote) { bSingleQuote = false; bHaveQuote = false; AddAttribute(strName, strValue); strName = ""; strValue = ""; eState = AttributeState.Nothing; } break; } default: // ??? this is bad??? Ignore for now! break; } break; } case '\"': { switch (eState) { case AttributeState.StartValue: eState = AttributeState.InValue; bHaveQuote = true; bSingleQuote = false; break; case AttributeState.InValue: { if (bHaveQuote && bSingleQuote) { strValue += "\""; } else if (bHaveQuote && !bSingleQuote) { bSingleQuote = false; bHaveQuote = false; AddAttribute(strName, strValue); strName = ""; strValue = ""; eState = AttributeState.Nothing; } break; } default: // ??? this is bad??? Ignore for now! break; } break; } default: { switch (eState) { case AttributeState.AfterName: { AddAttribute(strName, strName.ToLower()); strName = ""; strValue = ""; eState = AttributeState.Nothing; break; } case AttributeState.StartValue: strValue = chFind.ToString(); eState = AttributeState.InValue; break; case AttributeState.Nothing: strName += chFind; eState = AttributeState.Name; break; case AttributeState.Name: strName += chFind; break; case AttributeState.InValue: strValue += chFind; break; default: break; } break; } } } AddAttribute(strName, strValue); return; }