| | |
Python And XML
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
Hello everyone! 
I would like to read a xml file in order to return the content as a HTML response. I wonder if i need to parse the XML file or i can read the file as if it were an txt file. I am interested in this second way because i dont need to get part of the xml file,i just want to return every its content.
Thanks in advance...

I would like to read a xml file in order to return the content as a HTML response. I wonder if i need to parse the XML file or i can read the file as if it were an txt file. I am interested in this second way because i dont need to get part of the xml file,i just want to return every its content.
Thanks in advance...
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
Thanks for the help. I have tried unsuccessfully the following:
f=open('file.xml', 'r')
req.content_type='text/html'
req.write("<html>Reading...")
line=f.readline()
req.write(line)
req.write("</html>")
I tried the same with a txt file and it works,that is why im a bit confussed.
Thanks beforehand..
f=open('file.xml', 'r')
req.content_type='text/html'
req.write("<html>Reading...")
line=f.readline()
req.write(line)
req.write("</html>")
I tried the same with a txt file and it works,that is why im a bit confussed.
Thanks beforehand..
Last edited by currupipi; Apr 5th, 2009 at 6:39 pm.
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
Hi again. I think i know a new thing about my problem.
I actually can open xml files and read the content. But i stops reading when it finds characters like <AS>. For example,if my xml file is:
This is my xml<>
It reads fine.
But when i start to fill in the tags,it does not read them. For example,it does not read "<a>" in case my xml file content is the following
This is my xml <a>
Thanks for helping
I actually can open xml files and read the content. But i stops reading when it finds characters like <AS>. For example,if my xml file is:
This is my xml<>
It reads fine.
But when i start to fill in the tags,it does not read them. For example,it does not read "<a>" in case my xml file content is the following
This is my xml <a>
Thanks for helping
Last edited by currupipi; Apr 6th, 2009 at 7:46 am.
![]() |
Similar Threads
- Integrating python and Google calendar? (Python)
- XML reading (Python)
- Reading XML data (Python)
- Why should i learn Python? (Python)
- Searching and Comparing strings from an XML Document (Python)
- XML advice (Python)
- Parsing xml file (Python)
- http://www.ultracoder.com (PHP)
Other Threads in the Python Forum
- Previous Thread: Dictionaries python
- Next Thread: Looking for quit command
| Thread Tools | Search this Thread |
alarm assignment avogadro beginner bluetooth character cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples exe file float format function generator gnu graphics gui halp homework http ideas import input itunes java leftmouse line linux list lists logging loop maintain maze module mouse mysqldb number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh stdout string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 variable variables ventrilo verify vigenere web webservice wikipedia windows wxpython xlib






