offset = aSource.Find(aAttribute); if (-1 != offset) { offset = aSource.FindChar('=', PR_FALSE,offset);  PRUnichar next = aSource.CharAt(++offset); if (kQuote == next) { endOffset = aSource.FindChar(kQuote,PR_FALSE, ++offset); } else if (kApostrophe == next) { endOffset = aSource.FindChar(kApostrophe, PR_FALSE,++offset); }  if (-1 != endOffset) { aSource.Mid(aValue, offset, endOffset-offset); } else {  result = NS_ERROR_FAILURE; } } else { aValue.Truncate(); }
while (startOfAttribute != -1) {  startOfAttribute = aSource.Find(aAttribute, PR_FALSE, startOfAttribute);  if (startOfAttribute != -1) {  startOfValue = FindWhileSkippingWhitespace(aSource, '=', startOfAttribute + aAttribute.Length());  if (startOfValue != -1) { PRUnichar delimeter = kQuote;  posnOfValueDelimeter = FindWhileSkippingWhitespace(aSource, kQuote, startOfValue + 1); if (posnOfValueDelimeter == -1) { posnOfValueDelimeter = FindWhileSkippingWhitespace(aSource, kApostrophe, startOfValue + 1); delimeter = kApostrophe; }  if (posnOfValueDelimeter != -1) { startOfValue = posnOfValueDelimeter + 1;  posnOfValueDelimeter = aSource.FindChar(delimeter, PR_FALSE, startOfValue);  if (posnOfValueDelimeter != -1) {   aSource.Mid(aValue, startOfValue, posnOfValueDelimeter - startOfValue); result = NS_OK; break; } else {  startOfAttribute++; continue; } } else {  startOfAttribute++; continue; } } else {  startOfAttribute++; continue; } } }
GetQuotedAttributeValue(nsString& aSource,                        const nsString& aAttribute,                        nsString& aValue){  PRInt32 offset;  PRInt32 endOffset = -1;  nsresult result = NS_OK;  offset = aSource.Find(aAttribute);  if (-1 != offset) {    offset = aSource.FindChar('=', PR_FALSE,offset);    PRUnichar next = aSource.CharAt(++offset);    if (kQuote == next) {      endOffset = aSource.FindChar(kQuote,PR_FALSE, ++offset);    }    else if (kApostrophe == next) {      endOffset = aSource.FindChar(kApostrophe, PR_FALSE,++offset);    }    if (-1 != endOffset) {      aSource.Mid(aValue, offset, endOffset-offset);    }    else {      // Mismatched quotes - return an error      result = NS_ERROR_FAILURE;    }  }  else {    aValue.Truncate();  }  return result;}