+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * FCKXml Class: class to load and manipulate XML files.\r
- * (IE specific implementation)\r
- */\r
-\r
-var FCKXml = function()\r
-{\r
- this.Error = false ;\r
-}\r
-\r
-FCKXml.GetAttribute = function( node, attName, defaultValue )\r
-{\r
- var attNode = node.attributes.getNamedItem( attName ) ;\r
- return attNode ? attNode.value : defaultValue ;\r
-}\r
-\r
-/**\r
- * Transforms a XML element node in a JavaScript object. Attributes defined for\r
- * the element will be available as properties, as long as child element\r
- * nodes, but the later will generate arrays with property names prefixed with "$".\r
- *\r
- * For example, the following XML element:\r
- *\r
- * <SomeNode name="Test" key="2">\r
- * <MyChild id="10">\r
- * <OtherLevel name="Level 3" />\r
- * </MyChild>\r
- * <MyChild id="25" />\r
- * <AnotherChild price="499" />\r
- * </SomeNode>\r
- *\r
- * ... results in the following object:\r
- *\r
- * {\r
- * name : "Test",\r
- * key : "2",\r
- * $MyChild :\r
- * [\r
- * {\r
- * id : "10",\r
- * $OtherLevel :\r
- * {\r
- * name : "Level 3"\r
- * }\r
- * },\r
- * {\r
- * id : "25"\r
- * }\r
- * ],\r
- * $AnotherChild :\r
- * [\r
- * {\r
- * price : "499"\r
- * }\r
- * ]\r
- * }\r
- */\r
-FCKXml.TransformToObject = function( element )\r
-{\r
- if ( !element )\r
- return null ;\r
-\r
- var obj = {} ;\r
-\r
- var attributes = element.attributes ;\r
- for ( var i = 0 ; i < attributes.length ; i++ )\r
- {\r
- var att = attributes[i] ;\r
- obj[ att.name ] = att.value ;\r
- }\r
-\r
- var childNodes = element.childNodes ;\r
- for ( i = 0 ; i < childNodes.length ; i++ )\r
- {\r
- var child = childNodes[i] ;\r
-\r
- if ( child.nodeType == 1 )\r
- {\r
- var childName = '$' + child.nodeName ;\r
- var childList = obj[ childName ] ;\r
- if ( !childList )\r
- childList = obj[ childName ] = [] ;\r
-\r
- childList.push( this.TransformToObject( child ) ) ;\r
- }\r
- }\r
-\r
- return obj ;\r
-}\r