Beautiful soup how print a tag while iterating over it .
- by Bunny Rabbit
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<location>file:///home/ashu/Music/Collections/randomPicks/ipod%20on%20sep%2009/Coldplay-Sparks.mp3</location>
<title>Coldplay-Sparks</title>
</track>
<track>
<location>file:///home/ashu/Music/Collections/randomPicks/gud%201s/Coldplay%20Warning%20sign.mp3</location>
<title>Coldplay Warning sign</title>
</track>....
My xml looks like this , i want to get the locations,
i am trying
from BeautifulSoup import BeautifulSoup as bs
soup = bs (the_above_xml_text)
for track in soup.tracklist:
print track.location.string
but that is not working because i am getting
AttributeError: 'NavigableString' object has no attribute 'location'
how can i achive the result , thanks in advance.