473,395 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
1 1525
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hans Nowak | last post by:
Howdy y'all, The following works in Python 2.2.2: Python 2.2.2 (#37, Oct 14 2002, 17:02:34) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from...
5
by: Skip Montanaro | last post by:
I'd like to compare two xml.dom.minidom objects, but the naive attempt fails: >>> import xml.dom.minidom >>> d1 = xml.dom.minidom.parse("ES.xml") >>> d2 = xml.dom.minidom.parse("ES.xml") >>> d1...
6
by: Horst Gutmann | last post by:
Hi :-) I currently have quite a big problem with minidom and special chars (for example ü) in HTML. Let's say I have following input file:...
4
by: frankabel | last post by:
Hi all! I have the following xml file: " <items> <item>hi</item> <item>hello</item> </items> " and need to read all the content between <items> and </items> tags and saved in a string, in...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
0
by: Gary | last post by:
Howdy I ran into a difference between Python on Windows XP and Linux Fedora 6. Writing a dom to xml with minidom works on Linux. It gives an error on XP if there is an empty namespace. The...
3
by: aine_canby | last post by:
Hi, I'm working with a number of scripts which were written years ago for my company for Python 2.2, and I'd like to update for Python 2.5. I have written a script to add # -*- coding: cp1252...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.