Programming 4 - XML Parsing on Python

Put your programming skills to the test in these challenges.

Programming 4 - XML Parsing on Python

Post by Staticxor on Wed Dec 30, 2009 9:13 am
([msg=32341]see Programming 4 - XML Parsing on Python[/msg])

Hello,

I am having some problems in this mission in the XML part. My line/arcs drawing are working great (tested manually).
The problem is that I tryed using elementTree and cElementTree to parse de XML doc, but the XMLBuilder just doesn't work. I got the libs from the official site and the latest version and installed.

What libs did you use to parse the doc in Python? I think it is possible using regex (re), but it would be so complicated. I don't know, my Python 2.6.4 didn't came with XML libs. Could anyone help me to see the light?

Thx in advance.
Staticxor
New User
New User
 
Posts: 15
Joined: Sat Dec 26, 2009 9:05 am
Blog: View Blog (0)


Re: Programming 4 - XML Parsing on Python

Post by kijibwa on Wed Dec 30, 2009 9:48 am
([msg=32342]see Re: Programming 4 - XML Parsing on Python[/msg])

I just used minidom from xml.dom.I'm pretty sure it's a native python library .
Btw, i found that Tkinter gives better results than PIL.
User avatar
kijibwa
New User
New User
 
Posts: 18
Joined: Tue Apr 14, 2009 5:02 pm
Blog: View Blog (0)


Re: Programming 4 - XML Parsing on Python

Post by Staticxor on Wed Dec 30, 2009 2:32 pm
([msg=32363]see Re: Programming 4 - XML Parsing on Python[/msg])

kijibwa wrote:I just used minidom from xml.dom.I'm pretty sure it's a native python library .
Btw, i found that Tkinter gives better results than PIL.


When I give "from xml.dom import minidom" I get back:

Code: Select all
Traceback (most recent call last):
  File "xml.py", line 3, in <module>
    from xml.dom import minidom
  File "/home/static/workspace/pc 4/xml.py", line 3, in <module>
    from xml.dom import minidom
ImportError: No module named dom


So strange =/

Edit: Nvm, I realized that this occurs: http://www.raditha.com/blog/archives/001759.html
The lesson here: whenever I see an ImportError: No module named xxx I should immidiately check my choice of filename.
My script name was xml.py the same name of the lib I was trying to import. I will take a closer look at DOM. I felt kinda noobish here, but I program in python for less than a week, so that's ok. Thanks!

Just for curiosity, how exactly Tkinter gives better results than PIL? It shouldn't be the same draw??
Staticxor
New User
New User
 
Posts: 15
Joined: Sat Dec 26, 2009 9:05 am
Blog: View Blog (0)


Re: Programming 4 - XML Parsing on Python

Post by kijibwa on Wed Dec 30, 2009 5:28 pm
([msg=32377]see Re: Programming 4 - XML Parsing on Python[/msg])

Staticxor wrote:The lesson here: whenever I see an ImportError: No module named xxx I should immidiately check my choice of filename. My script name was xml.py the same name of the lib I was trying to import.

No worries, I've done the same thing a few times. :oops:
I don't know the techie details, but for this mission Tkinter gave me better resolution of the curves and the
accuracy of where curve met line was better in Tkinter than with PIL.
User avatar
kijibwa
New User
New User
 
Posts: 18
Joined: Tue Apr 14, 2009 5:02 pm
Blog: View Blog (0)


Re: Programming 4 - XML Parsing on Python

Post by Staticxor on Thu Dec 31, 2009 11:31 am
([msg=32462]see Re: Programming 4 - XML Parsing on Python[/msg])

Completed this one!
Thanks a lot for the hint. Minidom and Tkinker was really useful, the drawing of arcs was better than PIL and I made a GUI for automated submission with the image generated as background. I think I retrived the answer with less then 1 minute :D
Staticxor
New User
New User
 
Posts: 15
Joined: Sat Dec 26, 2009 9:05 am
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests