private XmlDeclaration LoadDeclarationNode()
{
Debug.Assert(_reader.NodeType == XmlNodeType.XmlDeclaration);
//parse data
string version = null;
string encoding = null;
string standalone = null;
// Try first to use the reader to get the xml decl "attributes". Since not all readers are required to support this, it is possible to have
// implementations that do nothing
while (_reader.MoveToNextAttribute())
{
switch (_reader.Name)
{
case "version":
version = _reader.Value;
break;
case "encoding":
encoding = _reader.Value;
break;
case "standalone":
standalone = _reader.Value;
break;
default:
Debug.Fail("Unknown reader name");
break;
}
}
// For readers that do not break xml decl into attributes, we must parse the xml decl ourselves. We use version attr, b/c xml decl MUST contain
// at least version attr, so if the reader implements them as attr, then version must be present
if (version == null)
ParseXmlDeclarationValue(_reader.Value, out version, out encoding, out standalone);
return _doc.CreateXmlDeclaration(version, encoding, standalone);
}