src/HarmonyHub/StreamParser.cs
/// <summary>
/// Reads the XML stream up to the 'stream:stream' opening tag.
/// </summary>
/// <exception cref="XmlException">The parser has encountered invalid
/// or unexpected XML data.</exception>
/// <exception cref="CultureNotFoundException">The culture specified by the
/// XML-stream in it's 'xml:lang' attribute could not be found.</exception>
Reads the XML stream up to the 'stream:stream' opening tag.
Reads the XML stream up to the ' stream : stream ' opening tag .
private void ReadRootElement()
        {
            while (_reader.Read())
            {
                switch (_reader.NodeType)
                {
                    case XmlNodeType.XmlDeclaration:
                        break;
                    case XmlNodeType.Element:
                        if (_reader.Name == "stream:stream")
                        {
                            string lang = _reader.GetAttribute("xml:lang");
                            if (!string.IsNullOrEmpty(lang))
                                Language = new CultureInfo(lang);
                            return;
                        }
                        throw new XmlException("Unexpected document root: " + _reader.Name);
                    default:
                        throw new XmlException("Unexpected node: " + _reader.Name);
                }
            }
            throw new Exception("Failed to read root node");
        }
private void ReadRootElement ( ) { while ( _reader . Read ( ) ) { switch ( _reader . NodeType ) { case XmlNodeType . XmlDeclaration : break ; case XmlNodeType . Element : if ( _reader . Name == " " ) { string lang = _reader . GetAttribute ( " " ) ; if ( ! string . IsNullOrEmpty ( lang ) ) Language = new CultureInfo ( lang ) ; return ; } throw new XmlException ( " " + _reader . Name ) ; default : throw new XmlException ( " " + _reader . Name ) ; } } throw new Exception ( " " ) ; }
Reads the XML stream up to the 'stream:stream' opening tag.
Reads the XML stream up to the ' stream : stream ' opening tag .
// Skip optional XML declaration. // Remember the default language communicated by the server. // If we got this far, the stream failed to establish
The parser has encountered invalid
or unexpected XML data.
The parser has encountered invalid or unexpected XML data .
The culture specified by the
XML-stream in it's 'xml:lang' attribute could not be found.
The culture specified by the XML - stream in it ' s ' xml : lang ' attribute could not be found .