1 | /*
|
---|
2 | function loadAsync(sUri, SOAPMessage) {
|
---|
3 | var xmlHttp = XmlHttp.create();
|
---|
4 | xmlHttp.open("POST", sUri, true);
|
---|
5 | xmlHttp.onreadystatechange = function () {
|
---|
6 | if (xmlHttp.readyState == 4){
|
---|
7 | getTitle2(xmlHttp.responseXML, xmlHttp.responseText);
|
---|
8 | }
|
---|
9 | }
|
---|
10 | xmlHttp.setRequestHeader("SOAPAction", " ");
|
---|
11 | xmlHttp.setRequestHeader("Content-Type", "Content-Type: text/xml; charset=utf-8");
|
---|
12 |
|
---|
13 | xmlHttp.send(SOAPMessage);
|
---|
14 | }
|
---|
15 | */
|
---|
16 |
|
---|
17 | function messageToSOAP(message) {
|
---|
18 | return ['<?xml version="1.0" encoding="UTF-8"?>',
|
---|
19 | '<soapenv:Envelope ',
|
---|
20 | 'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"',
|
---|
21 | 'xmlns:xsd="http://www.w3.org/2001/XMLSchema"',
|
---|
22 | 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',
|
---|
23 | '<soapenv:Body>',
|
---|
24 | message,
|
---|
25 | '</soapenv:Body>',
|
---|
26 | '</soapenv:Envelope>'].join("");
|
---|
27 | }
|
---|
28 |
|
---|
29 | function getText(element) { //get the text from possibly multiple text nodes
|
---|
30 | if (element.hasChildNodes()) {
|
---|
31 | var tempString = [];
|
---|
32 | for (var j = 0; j < element.childNodes.length; j++) {
|
---|
33 | if (element.childNodes[j].nodeType == Node.TEXT_NODE ) { // =2
|
---|
34 | tempString.push(element.childNodes[j].nodeValue);
|
---|
35 | }
|
---|
36 | else {
|
---|
37 | tempString.push('non text node: ');
|
---|
38 | }
|
---|
39 | }
|
---|
40 | return tempString.join("");
|
---|
41 | }
|
---|
42 | else {
|
---|
43 | return 'getText: element has no ChildNodes from which to extract Text';
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | function newOpenTag(name) {
|
---|
48 | return ['<', name, '>'].join("");
|
---|
49 | }
|
---|
50 |
|
---|
51 | function newCloseTag(name) {
|
---|
52 | return ['</', name, '>'].join("");
|
---|
53 | }
|
---|
54 |
|
---|
55 | function newEmptyTag(name) {
|
---|
56 | return ['<', name, '/>'].join("");
|
---|
57 | }
|
---|
58 |
|
---|
59 | function newElement(name, content) {
|
---|
60 | return ['<', name, '>', content, '</', name, '>'].join("");
|
---|
61 | }
|
---|
62 |
|
---|
63 | function newElementAtt1(name, content, attName, attValue) {
|
---|
64 | return ['<', name, ' ', attName, '="', attValue, '">', content, '</', name, '>'].join("");
|
---|
65 | }
|
---|
66 |
|
---|
67 | function newElementAtt(name, content, nameArray, valueArray) {
|
---|
68 | var e = ['<', name, ' '];
|
---|
69 | for (i=0; i < nameArray.length; i++) {
|
---|
70 | e.push(newAttribute(nameArray[i], valueArray[i]));
|
---|
71 | }
|
---|
72 | e.push(['>', content, '</', name, '>']);
|
---|
73 | return e.join("");
|
---|
74 | }
|
---|
75 |
|
---|
76 | function newAttribute(name, value) {
|
---|
77 | return [' ', name, '="', value, '"'].join("");
|
---|
78 | }
|
---|
79 |
|
---|
80 | function countElementChildren(node) {
|
---|
81 | var count = 0;
|
---|
82 | var childList = node.childNodes;
|
---|
83 | for(var i=0; i < (childList.length); i++) {
|
---|
84 | var childNode = childList.item(i);
|
---|
85 | if ((childNode.nodeType == 1)) { // only count elements
|
---|
86 | count++;
|
---|
87 | }
|
---|
88 | }
|
---|
89 | return count;
|
---|
90 | }
|
---|
91 |
|
---|
92 | function removeAllChildren(node) {
|
---|
93 | while (node.hasChildNodes()) {
|
---|
94 | node.removeChild(node.firstChild);
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | function isElement(node) {
|
---|
99 | if (node.nodeType == 1) {
|
---|
100 | return true; }
|
---|
101 | else {
|
---|
102 | return false;
|
---|
103 | }
|
---|
104 | } |
---|