songs.xml如下,
<SONGS>
<TITLE>想你的三百六十五天</TITLE>
<TITLE>人间烟火</TITLE>
<TITLE>半个月亮爬上来</TITLE>
<TITLE>真爱</TITLE>
<TITLE>窗外</TITLE>
<TITLE>幸福的地图</TITLE>
<TITLE>华丽的冒险</TITLE>
<TITLE>心驰神往</TITLE>
<TITLE>偏偏喜欢你</TITLE>
<TITLE>泉水叮咚响</TITLE>
<TITLE>当大雨过后</TITLE>
<TITLE>阳光下的星星</TITLE>
</SONGS>
===========
下面是python的代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from xml.dom.minidom import parse
import xml.dom.minidom
import sys
try:
xmlfile = open("songs.xml", "r")
xmldoc = minidom.parse(xmlfile)
except :
sys.exit(0)
songs = xmldoc.getElementsByTagName('SONGS')[0]
for r in songs:
IssueID = r.getElementsByTagName('TITLE')[0]
for node in IssueID.childNodes:
if node.nodeType in (node.TEXT_NODE, node.CDATA_SECTION_NODE):
print(node.data)
--
修改:javame FROM 124.78.137.*
FROM 124.78.137.*