PageRenderTime 24ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR/EDUAR_UI/Private/Manuales/Docente/xmlengine.js

http://blpm.googlecode.com/
JavaScript | 62 lines | 44 code | 6 blank | 12 comment | 12 complexity | 133107e8fb98ad6b4eb4dae8297f2eba MD5 | raw file
 1//XML load routines
 2 XMLload = function(url) {
 3	if (saf)
 4	{
 5        var d = new XMLHttpRequest();
 6        d.open("GET", url, false);
 7        d.send(null);
 8		return d.responseXML;
 9	}
10    var xmldoc = XMLnewDocument();
11    xmldoc.async = false;  
12    xmldoc.load(url);
13    return xmldoc;  
14  };
15
16
17XMLnewDocument = function(rootTagName, namespaceURL) {
18    if (!rootTagName) rootTagName = "";
19    if (!namespaceURL) namespaceURL = "";
20
21    if (document.implementation && document.implementation.createDocument) {
22        // This is the W3C standard way to do it
23        return document.implementation.createDocument(namespaceURL, 
24                       rootTagName, null);
25    }
26    else { // This is the IE way to do it
27        // Create an empty document as an ActiveX object
28        // If there is no root element, this is all we have to do
29        var doc = new ActiveXObject("MSXML2.DOMDocument");
30
31        // If there is a root tag, initialize the document
32        if (rootTagName) {
33            // Look for a namespace prefix
34            var prefix = "";
35            var tagname = rootTagName;
36            var p = rootTagName.indexOf(':');
37            if (p != -1) {
38                prefix = rootTagName.substring(0, p);
39                tagname = rootTagName.substring(p+1);
40            }
41
42            // If we have a namespace, we must have a namespace prefix
43            // If we don't have a namespace, we discard any prefix
44            if (namespaceURL) {
45                if (!prefix) prefix = "a0"; // What Firefox uses
46            }
47            else prefix = "";
48
49            // Create the root element (with optional namespace) as a
50            // string of text
51            var text = "<" + (prefix?(prefix+":"):"") + tagname +
52                (namespaceURL
53                 ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
54                 :"") +
55                "/>";
56            // And parse that text into the empty document
57            doc.loadXML(text);
58        }
59        return doc;
60    }
61}; 
62//END OF XML load routines