Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to read data from xml file
#4
It still give error,
Below is my code:

[python][python]import xml.etree.cElementTree as ET
tree = ET.ElementTree('input.xml')
root = tree.getroot()
for books in root:
    if (books.tag=='book'):
        print books.get('id') % here it says invalid syntax
        for attr in books:
            if (attr.tag=='author'):
                print (attr.text)
[/python][/python]
Reply


Messages In This Thread
how to read data from xml file - by Raj - Apr-13-2018, 02:21 PM
RE: how to read data from xml file - by dwill - Apr-13-2018, 04:09 PM
RE: how to read data from xml file - by Larz60+ - Apr-13-2018, 08:18 PM
RE: how to read data from xml file - by Raj - Apr-14-2018, 05:26 AM
RE: how to read data from xml file - by dwill - Apr-14-2018, 06:39 AM
RE: how to read data from xml file - by Raj - Apr-14-2018, 10:31 AM
RE: how to read data from xml file - by snippsat - Apr-14-2018, 11:49 AM
RE: how to read data from xml file - by Raj - Apr-14-2018, 12:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Open and read a tab delimited file from html using python cgi luffy 2 2,686 Aug-24-2020, 06:25 AM
Last Post: luffy
  Read owl file using python flask Gayathri 1 2,465 Nov-20-2019, 12:56 PM
Last Post: ChislaineWijdeven
  Read XML-File yuyu 16 7,174 Dec-15-2018, 10:49 PM
Last Post: snippsat
  Read input file and print hyperlinks Emmanouil 8 15,240 Oct-23-2016, 07:26 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020