How can I find a specific node in my XML?

前端 未结 5 1782
别跟我提以往
别跟我提以往 2021-01-01 22:28

I have to read the xml node \"name\" from the following XML, but I don\'t know how to do it.

Here is the XML:



        
5条回答
  •  孤独总比滥情好
    2021-01-01 23:12

    import xml.etree.ElementTree as ET
    
    tree= ET.parse('name.xml')
    root= tree.getroot()
    
    print root[0][0].text
    
    • root = games
    • root[0] = game
    • root[0][0] = name
    • root[0][1] = url
    • use the ".text" to get string representation of value
    • this example is using python

提交回复
热议问题