Warning: file_exists(): open_basedir restriction in effect. File(/simple_html_dom.php) is not within the allowed path(s): (/var/lib/nginx/tmp/client:/var/www:/usr/bin:/dev/urandom:/proc/meminfo:/var/log/php) in _simplhtmldom_get_library_path() (Zeile 27 von sites/all/modules/simplehtmldom/helper.inc).
XML-Formater
2009-1104
#!/usr/bin/pythonimportfileinputimportosimportreimportshutilimportsysimporttempfile# (c) 2009 mig@xilab.net def pr(s, level):
print'\t'*level + s
def format(data):
fields =re.split('(<.*?>)', data.replace('\r\n','\n').replace('\r','\n'))
level =0
l =0while l <len(fields):
f = fields[l]
l = l + 1if f.strip()=='':
continueif f[0]=='<'and f[1]notin['/','?','!']:
if fields[l][:2]=='</':
f = f + fields[l]
l = l + 1
pr(f, level)elif fields[l+1][:2]=='</':
f = f + fields[l].strip() + fields[l+1]
l = l + 2
pr(f, level)elif f[-2:]!='/>':
pr(f, level)
level = level + 1else:
if f[:2]=='</':
level = level - 1
pr(f, level)
data =sys.stdin.read()
format(data)#:set shiftwidth=4|set expandtab|set tabstop=4