473,386 Members | 2,114 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,386 software developers and data experts.

Possible error in 'dive into Python' book, help!

I have been going through Dive into Python which up to now has been
excellent. I am now working through Chapter 9, XML Processing. I am 9
pages in (p182) in the 'Parsing XML section. The following code is
supposed to return the whole XML document (I have put ti at the end of
this email):

from xml.dom import minidom

xmldoc =
minidom.parse('/home/ben/diveintopython-5.4/py/kgp/binary.xml')
grammerNode = xmldoc.firstChild

print grammerNode.toxml()

But it only returns:

<!DOCTYPE grammar
PUBLIC '-//diveintopython.org//DTD Kant Generator Pro v1.0//EN'
'kgp.dtd'>

The next line is then

grammerNode.childNodes

And it returns an empty tuples;(

Kind of stuck here as I don't really want to continue. Has anyone any
idea what is going on?

Ben

binary.xml

<?xml version="1.0"?>
<!DOCTYPE grammar PUBLIC "-//diveintopython.org//DTD Kant Generator Pro
v1.0//EN" "kgp.dtd">
<grammar>
<ref id="bit">
<p>0</p>
<p>1</p>
</ref>
<ref id="byte">
<p><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref
id="bit"/><xref id="bit"/><xref id="bit"/><xref id="bit"/><xref
id="bit"/></p>
</ref>
</grammar>


Jul 28 '06 #1
0 1044

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Franz Mueller | last post by:
Hi, which of the following books would you recommend: "Dive into Python" or "Beginning Python: From Novice to Professional"? I'm an experienced C++-programmer who wants to take a look at...
5
by: Casey Hawthorne | last post by:
Since there was talk of if-then-else not being allowed in lambda expressions, the following is from "Dive into Python" The and-or conditional expression trick from page 41 of "Dive into Python"...
3
by: hanumizzle | last post by:
I find Dive Into Python generally an excellent text, and I am not surprised to see people recommending it...but I have noticed a few errors already: ...
1
by: Ben Edwards (lists) | last post by:
I have been going through Dive into Python which up to now has been excellent. I am now working through Chapter 9, XML Processing. I am 9 pages in (p182) in the 'Parsing XML section. The...
2
by: Fred C. Dobbs | last post by:
I feel like an idiot. I'm going thru "Dive Into Python" and running the first program - odbchelper.py My output is "pwd=secret;database=master;uid=sa;server=mpilgrim" which has all the...
32
by: Licheng Fang | last post by:
Basically, the problem is this: 'do' Python's NFA regexp engine trys only the first option, and happily rests on that. There's another example: 'oneself' The Python regular expression...
51
by: erikcw | last post by:
DiveIntoPython.org was the first book I read on python, and I really got a lot out of it. I need to start learning Java (to maintain a project I've inherited), and was wondering if anyone knew of...
3
by: james_027 | last post by:
Hi, class UserDict: def __init__(self, dict=None): self.data = {} if dict is not None: self.update(dict) I just don't understant this code, as it is not also mention in the book. the update...
3
by: webandwe | last post by:
Hi, Does anyone know where I can get a free scuba dive log book module, I want user to be able login and then the module must display all of their dive. Otherwise how/what do I need to do to...
8
by: jonbutler88 | last post by:
Just writing a simple website spider in python, keep getting these errors, not sure what to do. The problem seems to be in the feed() function of htmlparser. Traceback (most recent call last):...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
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...

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.