import xml.dom.minidom
xmlroot = xml.dom.monodom.parse('./.repo/manifest.xml')
這樣 parsing 完,就可以用 xmlroot 這個變數操作。
xml 是階層式的架構,所以每一個 node 都有 childNodes[]。
每個 nodes 還有 attribute。
for node in xml.childnodes:
if node.Name == 'project':
print node.getAttribute('path')
印出所有第一階, node name 是 project 的 path
沒有留言:
張貼留言