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