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.getEleme ntsByTagName('D ocNumb')[0].firstChild.dat a.encode('latin 1')
(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 1 1555
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.getEleme ntsByTagName('D ocNumb')[0].firstChild.dat a.encode('latin 1')
(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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 xml.dom.minidom import Text
>>> t = Text("foo")
>>> t
<DOM Text node "foo">
|
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 == d2
False
My goal is to decide whether or not I need to prompt the user to save config
information at the end of a program run by generating a minidom object then
|
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:
--------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
|
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 this case:
|
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 Developer (SP3 for Office, SP1 for developer,
JET40SP8) on Windows XP Home Edition (SP1). The same behaviour occurs
on Windows 98 too.
| |
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;
|
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 problem was handled in CVS a
while ago.
http://mail.python.org/pipermail/xml-sig/2003-October/009904.html
|
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 -*- to the beginning
of all my scripts, and that has fixed the encoding issues.
Another issue was the use of -
from _xmlplus.dom import minidom
|
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. (Sorry, long email)
The first two examples are behaving normal, the thirth is
strange.......
I wrote the following flabbergasting code:
#-------------------------------------------------------------
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |