/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. XMLnewDocument = function(rootTagName, namespaceURL) {
  16. if (!rootTagName) rootTagName = "";
  17. if (!namespaceURL) namespaceURL = "";
  18. if (document.implementation && document.implementation.createDocument) {
  19. // This is the W3C standard way to do it
  20. return document.implementation.createDocument(namespaceURL,
  21. rootTagName, null);
  22. }
  23. else { // This is the IE way to do it
  24. // Create an empty document as an ActiveX object
  25. // If there is no root element, this is all we have to do
  26. var doc = new ActiveXObject("MSXML2.DOMDocument");
  27. // If there is a root tag, initialize the document
  28. if (rootTagName) {
  29. // Look for a namespace prefix
  30. var prefix = "";
  31. var tagname = rootTagName;
  32. var p = rootTagName.indexOf(':');
  33. if (p != -1) {
  34. prefix = rootTagName.substring(0, p);
  35. tagname = rootTagName.substring(p+1);
  36. }
  37. // If we have a namespace, we must have a namespace prefix
  38. // If we don't have a namespace, we discard any prefix
  39. if (namespaceURL) {
  40. if (!prefix) prefix = "a0"; // What Firefox uses
  41. }
  42. else prefix = "";
  43. // Create the root element (with optional namespace) as a
  44. // string of text
  45. var text = "<" + (prefix?(prefix+":"):"") + tagname +
  46. (namespaceURL
  47. ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
  48. :"") +
  49. "/>";
  50. // And parse that text into the empty document
  51. doc.loadXML(text);
  52. }
  53. return doc;
  54. }
  55. };
  56. //END OF XML load routines