flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject [21/42] git commit: [flex-asjs] [refs/heads/feature/amf] - Made finding errorNS more efficient I think this fixed MS browsers Better XML errors
Date Sun, 13 Aug 2017 22:04:14 GMT
Made finding errorNS more efficient
I think this fixed MS browsers
Better XML errors


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/10be5b82
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/10be5b82
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/10be5b82

Branch: refs/heads/feature/amf
Commit: 10be5b82ff91db9ec77966ba6d8c7c37defa6f81
Parents: 19fa436
Author: Harbs <harbs@in-tools.com>
Authored: Fri Aug 4 15:15:40 2017 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Fri Aug 4 15:15:40 2017 +0300

----------------------------------------------------------------------
 frameworks/projects/XML/src/main/flex/XML.as | 30 +++++++++++++++++------
 1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/10be5b82/frameworks/projects/XML/src/main/flex/XML.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/XML/src/main/flex/XML.as b/frameworks/projects/XML/src/main/flex/XML.as
index f09a018..7970df1 100644
--- a/frameworks/projects/XML/src/main/flex/XML.as
+++ b/frameworks/projects/XML/src/main/flex/XML.as
@@ -339,18 +339,34 @@ package
 			);
 			
 		}
-
+		private static var errorNS:String;
 		private function parseXMLStr(xml:String):void
 		{
 			var parser:DOMParser = new DOMParser();
-			// get error namespace. It's different in different browsers.
-			var errorNS:String = parser.parseFromString('<', 'application/xml').getElementsByTagName("parsererror")[0].namespaceURI;
-
-			var doc:Document = parser.parseFromString(xml, "application/xml");
+			if(errorNS == null)
+			{
+				// get error namespace. It's different in different browsers.
+				try{
+					errorNS = parser.parseFromString('<', 'application/xml').getElementsByTagName("parsererror")[0].namespaceURI;
+				}
+				catch(err:Error){
+					// Some browsers (i.e. IE) just throw an error
+					errorNS = "na";
+				}
+			}
+			try
+			{
+				var doc:Document = parser.parseFromString(xml, "application/xml");
+			}
+			catch(err:Error)
+			{
+				throw err;
+			}
 
 			//check for errors
-			if(doc.getElementsByTagNameNS(errorNS, 'parsererror').length > 0)
-				throw new Error('XML parse error');
+			var errorNodes:NodeList = doc.getElementsByTagNameNS(errorNS, 'parsererror');
+			if(errorNodes.length > 0)
+				throw new Error(errorNodes[0].innerHTML);
 			for(var i:int=0;i<doc.childNodes.length;i++)
 			{
 				var node:Element = doc.childNodes[i];


Mime
View raw message