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

Discussion in 'Python' started by Ben Edwards, Jul 28, 2006.

  1. Ben Edwards

    Ben Edwards Guest

    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>
     
    Ben Edwards, Jul 28, 2006
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis P. Mendes

    Dive into Python java equivalent

    Luis P. Mendes, May 13, 2005, in forum: Python
    Replies:
    0
    Views:
    410
    Luis P. Mendes
    May 13, 2005
  2. Franz Mueller
    Replies:
    6
    Views:
    691
    Anders Eriksson
    Nov 29, 2005
  3. Franz Mueller

    Dive into Python PDF

    Franz Mueller, Nov 30, 2005, in forum: Python
    Replies:
    2
    Views:
    643
    Paul Rubin
    Nov 30, 2005
  4. Replies:
    3
    Views:
    468
    cga2000
    Jul 26, 2006
  5. Ben Edwards (lists)

    Exercises for dive into python

    Ben Edwards (lists), Jul 24, 2006, in forum: Python
    Replies:
    0
    Views:
    372
    Ben Edwards (lists)
    Jul 24, 2006
  6. Ben Edwards (lists)

    Re: Exercises for dive into python

    Ben Edwards (lists), Jul 24, 2006, in forum: Python
    Replies:
    1
    Views:
    500
    Gerard Flanagan
    Jul 24, 2006
  7. Ben Edwards (lists)

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

    Ben Edwards (lists), Jul 28, 2006, in forum: Python
    Replies:
    1
    Views:
    392
    Sion Arrowsmith
    Jul 31, 2006
  8. Ben Edwards

    Nuther problem with 'dive into Python'

    Ben Edwards, Jul 31, 2006, in forum: Python
    Replies:
    0
    Views:
    328
    Ben Edwards
    Jul 31, 2006
Loading...