From bad23e8a2905ce1c65424c337841cbf016124ef0 Mon Sep 17 00:00:00 2001 From: Nick Zigarovich Date: Mon, 14 Oct 2002 06:22:08 +0000 Subject: Make sure XmlTextReader.GetAttribute never returns null. svn path=/trunk/mcs/; revision=8237 --- mcs/class/System.XML/System.Xml/XmlTextReader.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mcs/class/System.XML/System.Xml') diff --git a/mcs/class/System.XML/System.Xml/XmlTextReader.cs b/mcs/class/System.XML/System.Xml/XmlTextReader.cs index ded97250cbb..b51eb6ff3dc 100644 --- a/mcs/class/System.XML/System.Xml/XmlTextReader.cs +++ b/mcs/class/System.XML/System.Xml/XmlTextReader.cs @@ -330,7 +330,8 @@ namespace System.Xml public override string GetAttribute (string name) { - return attributes [name] as string; + return attributes.ContainsKey (name) ? + attributes [name] as string : String.Empty; } public override string GetAttribute (string localName, string namespaceURI) @@ -349,10 +350,12 @@ namespace System.Xml string thisNamespaceURI = LookupNamespace (thisPrefix); if (namespaceURI == thisNamespaceURI) - return attributes [thisName] as string; + return attributes.ContainsKey (thisName) ? + attributes [thisName] as string : String.Empty; } } else if (localName == "xmlns" && namespaceURI == "http://www.w3.org/2000/xmlns/" && thisName == "xmlns") - return attributes [thisName] as string; + return attributes.ContainsKey (thisName) ? + attributes [thisName] as string : String.Empty; } return String.Empty; -- cgit v1.2.3