I need some help. I am trying to display the value in a tabular format but getting the following error using Django and Python. The error is given below.
raise SyntaxError("invalid predicate")
SyntaxError: invalid predicate
def search(request):
per=[]
if request.method == 'POST':
rname=request.POST.get('rname')
serch=request.POST.get('searchby')
tree = ET.parse('roomlist.xml')
root = tree.getroot()
if serch==0:
xyz = './/*[roomname='
xyz = xyz + rname
xyz= xyz + ']'
result=root.findall(xyz)
for x in result:
per.append({'roomname':x.find('roomname').text,'seat':x.find('noseats').text,'project':x.find('projectorscreen').text,'video':x.find('videoconf').text})
return render(request,'booking/home.html',{'people': per})
My view part is given below.
home.html:
{% if people %}
<table>
<tr>
<th>Room Name</th>
<th>seats</th>
<th>Projector screen</th>
<th>Video Conference</th>
</tr>
{% for person in people %}
<tr>
<td>{{person.roomname}}</td>
<td>{{person.seat}}</td>
<td>{{person.project}}</td>
<td>{{person.video}}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>No Record in the database</p>
{% endif %}
I need to fetch all value from the below .xml
file.
<?xml version="1.0" ?><roomlist>
<location name="Bangalore">
<room id="1uy92j908u092">
<roomname> Aquarius </roomname>
<noseats> 10 </noseats>
<projectorscreen>yes</projectorscreen>
<videoconf>yes</videoconf>
</room>
</location>
<location name="Bhubaneswar"><room id="131198912460"><roomname>cottage</roomname><noseats>5</noseats><projectorscreen>Yes</projectorscreen><videoconf>Yes</videoconf></room></location><location name="puri"><room id="509955554930"><roomname>room1</roomname><noseats>10</noseats><projectorscreen>No</projectorscreen><videoconf>Yes</videoconf></room></location></roomlist>
Here I need to search all value from file and display. Please help me.