[XML-SIG] traversing xml tree is incomplete
Julien Motch
julienmotch at skynet.be
Mon Aug 4 10:57:17 EDT 2003
Hi All,
I am new to xml and experiencing problems by traversing an xml tree.
The python program is :
#audio.py
#!/usr/bin/python
import sys
from xml.dom.ext.reader import Sax2
from xml.dom.NodeFilter import NodeFilter
# create Reader object
reader = Sax2.Reader()
# parse the document
doc = reader.fromStream(sys.stdin)
walker = doc.createTreeWalker(doc.documentElement,
NodeFilter.SHOW_ELEMENT, None, 10)
while 1:
print walker.currentNode.tagName
next = walker.nextNode()
if next is None: break
it is called as it : cat afxc.xml & ./audio.xml
and the afx.xml file is :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE CDInfo SYSTEM "http://www.musicbrainz.org/dtd/CDInfo.dtd">
<CDInfo>
<Title>26 Mixes for Cash\Disc 1</Title>
<NumTracks>13</NumTracks>
<IdInfo>
<DiskId>
<Id>P_KmeuFUQTSj5Tymmor.07xxgyY-</Id>
</DiskId>
</IdInfo>
<SingleArtistCD>
<Artist>Aphex Twin</Artist>
<Track Num="1">
<Name>Time To Find Me (AFX Fast Mix) [Seefeel]</Name>
</Track>
<Track Num="2">
<Name>Raising The Titanic (Big Drum Mix) [Gavin Bryars]</Name>
</Track>
<Track Num="3">
<Name>Journey (Aphex Twin Care Mix) [Gentle People]</Name>
</Track>
<Track Num="4">
<Name>Triachus (Mix by Aphex Twin) [Kinesthesia]</Name>
</Track>
<Track Num="5">
<Name>Heroes (Aphex Twin Remix) [Philip Glass]</Name>
</Track>
<Track Num="6">
<Name>In The Glitter Part 2 (Aphex Twin Mix) [Buck Tick]</Name>
</Track>
<Track Num="7">
<Name>Zeroes and Ones (Aphex Twin Reconstruction #2) [Jesus
Jones]</Name>
</Track>
<Track Num="8">
<Name>Ziggy (Aphex Twin Mix #1) [Nav Katze]</Name>
</Track>
<Track Num="9">
<Name>Your Head My Voice (Voix Revirement) [Saint
Etienne]</Name>
</Track>
<Track Num="10">
<Name>Change (Aphex Twin Mix #2) [Nav Katze]</Name>
</Track>
<Track Num="11">
<Name>Une Femme N'est Pas Un Homme (Aphex Twin Mix) [The
Beatniks]</Name>
</Track>
<Track Num="12">
<Name>The Beauty of Being Numb Section B (Created by Aphex
Twin) [Nine Inch Nails]</Name>
</Track>
<Track Num="13">
<Name>Let My Fish Loose (Aphex Twin Remix) [Nobukazu
Takemura]</Name>
</Track>
</SingleArtistCD>
</CDInfo>
The output of the program is :
CDInfo
Title
NumTracks
IdInfo
DiskId
Id
which is quite strange as it does not print the track and name element .
but if I remove the lines :
<IdInfo>
<DiskId>
<Id>P_KmeuFUQTSj5Tymmor.07xxgyY-</Id>
</DiskId>
</IdInfo>
the the output seems normal and is :
CDInfo
Title
NumTracks
SingleArtistCD
Artist
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Track
Name
Is it a bug or is my xml file not well formed ?
Thanks ,Julien.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/xml-sig/attachments/20030804/e87bc60c/attachment.bin
More information about the XML-SIG
mailing list