Open ahmsayat opened 6 years ago
edit path:
open ~/.bash_profile
my working python version:
/usr/local/bin/python manage.py runserver
def to_xml(tree): doc = minidom.Document() root = doc.createElement('root') doc.appendChild(root) leaf = doc.createElement('leaf') leaf.setAttribute('color', 'white') text = doc.createTextNode('Text element with attributes') leaf.appendChild(text) root.appendChild(leaf) leaf_cdata = doc.createElement('leaf_cdata') cdata = doc.createCDATASection('CData can contain HTML tags without encoding') leaf_cdata.appendChild(cdata) root.appendChild(leaf_cdata) branch = doc.createElement('branch') branch.appendChild(leaf.cloneNode(True)) root.appendChild(branch) mixed = doc.createElement('mixed') mixed_leaf = leaf.cloneNode(True) mixed_leaf.setAttribute('color', 'black') mixed_leaf.setAttribute('state', 'modified') mixed.appendChild(mixed_leaf) mixed_text = doc.createTextNode('Do not use mixed elements if it possible.') mixed.appendChild(mixed_text) root.appendChild(mixed) xml_str = doc.toprettyxml(indent=" ") with open("minidom_example.xml", "w") as f: f.write(xml_str) return HttpResponse(xml_str, content_type='application/json')
urls: https://stackoverflow.com/questions/168113/django-how-do-i-create-a-generic-url-routing-to-views