467,168 Members | 990 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,168 developers. It's quick & easy.

strange DOM behaviour when using minidom

Hello, I have a really strange problem. I'm unable to figure it out on
my own.

I parse very simple xml documents, without any check for their form.
These files look very similar and are encoded in UTF-8.

Now minidom is always able to parse these files with
minidom.parse("file") .
Now when fetching I use this expression:
xmldoc.getElementsByTagName('DocNumb')[0].firstChild.data.encode('latin1')

(I know it's not beautiful but convenient. )

It always work, but sometimes it simply fails to fetch any element.
Redoing it from hand in the python console with the same file always
works.

I have no idea what the error is. I compared working and not working
files with the hex editor. I couldn't find any significant change. It's
too strange. If anybody has any clue, hint or anything, please let me
know.

Regards, Jonatan

Sep 11 '06 #1
  • viewed: 1302
Share:
1 Reply
Sorry, I just found the error. Simple an empty attribute. Python showed
me strange row numbers. I used a multi line initialization of a dict.
The error always appeared on the first line although I was on an other
line.

Interesting behavior.

Jonatan

JoReiners schrieb:
Hello, I have a really strange problem. I'm unable to figure it out on
my own.

I parse very simple xml documents, without any check for their form.
These files look very similar and are encoded in UTF-8.

Now minidom is always able to parse these files with
minidom.parse("file") .
Now when fetching I use this expression:
xmldoc.getElementsByTagName('DocNumb')[0].firstChild.data.encode('latin1')

(I know it's not beautiful but convenient. )

It always work, but sometimes it simply fails to fetch any element.
Redoing it from hand in the python console with the same file always
works.

I have no idea what the error is. I compared working and not working
files with the hex editor. I couldn't find any significant change. It's
too strange. If anybody has any clue, hint or anything, please let me
know.

Regards, Jonatan
Sep 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Skip Montanaro | last post: by
6 posts views Thread by Horst Gutmann | last post: by
4 posts views Thread by frankabel | last post: by
3 posts views Thread by Sebastian C. | last post: by
reply views Thread by Gary | last post: by
3 posts views Thread by aine_canby@yahoo.com | last post: by
8 posts views Thread by Dox33 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.