summaryrefslogtreecommitdiff
path: root/htroot/js/xml.js
blob: f987103352a914ad62e15d95de4b2d958cc02d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*    
* Copyright (C) 2006 Alexander Schier, Michael Peter Christen
*         
* This file is part of YaCy.
* 
* YaCy is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* 
* YaCy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with YaCy.  If not, see <http://www.gnu.org/licenses/>.
*/

function removeAllChildren(element){
	if(element==null){
		return;
	}
	child=element.firstChild;
	while(child!=null){
		element.removeChild(child);
		child=element.firstChild;
	}
}

function getValue(element){
	if(element == null){
		return "";
	}else if(element.nodeType == 3){ //Textnode
		return element.nodeValue;
	}else if(element.firstChild != null && element.firstChild.nodeType == 3){
		return element.firstChild.nodeValue;
	}
	return "";
}
function getFirstChild(element, childname){
	if(childname==null){
		childname="";
	}
	if(element == null){
		return null;
	}
	child=element.firstChild;
	while(child != null){
		if(child.nodeType!=3 && (child.nodeName.toLowerCase()==childname.toLowerCase() || childname=="")){
			return child;
		}
		child=child.nextSibling;
	}
	return null;
}
function getNextSibling(element, childname){
	if(childname==null){
		childname="";
	}
	if(element == null){
		return null;
	}
	child=element.nextSibling;
	while(child != null){
		if(child.nodeType==1 && (child.nodeName.toLowerCase()==childname.toLowerCase() || childname=="")){
			return child;
		}
		child=child.nextSibling;
	}
	return null;
}