private void SkipWhiteSpace()
{
// TODO: handle character entities while processing comments, cdata, and directives
// TODO: SUGGESTION: we could check if lookahead and previous characters are entities also
while (true)
{
if (_nextCharacter == '<' && (_lookAheadCharacter == '?' || _lookAheadCharacter == '!'))
{
this.GetNextCharacter();
if (_lookAheadCharacter == '[')
{
// Skip CDATA block and DTDs(?)
while (!this.IsAtEndOfStream && !(_previousCharacter == ']' && _nextCharacter == ']' && _lookAheadCharacter == '>'))
{
this.GetNextCharacter();
}
if (_nextCharacter == '>')
{
this.GetNextCharacter();
}
}
else
{
// Skip processing instruction, comments
while (!this.IsAtEndOfStream && _nextCharacter != '>')
{
this.GetNextCharacter();
}
if (_nextCharacter == '>')
{
this.GetNextCharacter();
}
}
}
if (!Char.IsWhiteSpace(this.NextCharacter))
{
break;
}
this.GetNextCharacter();
}
}