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

B

Ben Edwards

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top