[Mono-list] XmlTextReader class problem

mirek novak mndisc at gmail.com
Fri Dec 9 07:22:44 EST 2005


Oh, it is now. Have you added it or have I been blind?
Anyway thank you very much for pointing me.
But, as I have tested, it doesn't work as stated in documentation :(

There is exception rised
Unhandled Exception: System.NullReferenceException: Object reference
not set to an instance of an object
which is caused by calling unassigned Encoding property

$ mono --version
Mono JIT compiler version 1.1.8.1 ...

---code fragment ---
/// xmlFeed contains valid xml text with header
///  <?xml version="1.0" encoding="iso-8859-2"?>

            StringReader strReader = new StringReader(xmlFeed);
            XmlTextReader xml = new XmlTextReader(strReader);
            bool encSeen = false; // for displaying encoding only once
             while (xml.Read()) {
                 if (xml.ReadState == ReadState.Interactive && !encSeen) {
                      System.Console.WriteLine("{0} XML encoding {1}",
DateTime.Now, xml.Encoding.WebName);
                       encSeen = true;
                 }
             } // while
---code ends---

regards, Mirek
--
2005/12/9, Atsushi Eno <atsushi at ximian.com>:
> Well, isn't XmlTextReader.Encoding actually documented?
> http://www.go-mono.com/docs/monodoc.ashx?tlink=7@ecma%3a1376%23XmlTextReader%2fP%2f23
>
> Atsushi Eno
>


More information about the Mono-list mailing list