예제 #1
0
        internal override void WriteXmlDeclaration(string xmldecl)
        {
            VerifyState(Method.WriteXmlDeclaration);
            string version, encoding, standalone;

            XmlParsingHelper.ParseXmlDeclarationValue(xmldecl, out version, out encoding, out standalone);
            XmlNode node = _document.CreateXmlDeclaration(version, encoding, standalone);

            AddChild(node, _write);
        }
예제 #2
0
파일: XmlLoader.cs 프로젝트: theo949/corefx
        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.Assert(false);
                    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)
            {
                XmlParsingHelper.ParseXmlDeclarationValue(reader.Value, out version, out encoding, out standalone);
            }

            return(doc.CreateXmlDeclaration(version, encoding, standalone));
        }