In this article we will see how we can get the person information in the XML format. Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. Person object contains all the information about the person which is related to film industry and has records at IMDb data base.
In order to get this we have to do the following
1. Import the IMDbPY module
2. Create a instance of IMDB
3. Get the person object with the help of get_person method which requires movie ID
4. Get the XML format value here it will be in string by converting the person object into XML
Below is the implementation
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # id code = "1372788" # getting information person = ia.get_person(code) # printing name print(person['name']) print("--------------------------------") # converting person object into XML file xml_file = person.asXML() # printing some part of the XML file print(xml_file[:150]) |
Output :
Shahid Kapoor -------------------------------- <?xml version="1.0"? <!DOCTYPE person SYSTEM "http://imdbpy.sf.net/dtd/imdbpy68.dtd" <birth-info key="bir
Another example
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # id code = "2690647" # getting information person = ia.get_person(code) # printing name print(person['name']) print("--------------------------------") # converting person object into XML file xml_file = person.asXML() # printing some part of the XML file print(xml_file[:250]) |
Output :
Pankaj Tripathi -------------------------------- <?xml version="1.0"? <!DOCTYPE person SYSTEM "http://imdbpy.sf.net/dtd/imdbpy68.dtd" https://m.media-amazon.com/images/M/MV5BNjdlYjllOGMtYzU1OC00ODZjLWEzOGEtMGViOTYyYjU3YmJiXk
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python IMDbPY – Series Information in XML format
- Python IMDbPY – Company Information in XML format
- Python IMDbPY – Movies Information in XML format
- Python IMDbPY – Retrieving person using person ID
- Python IMDbPY – Person info set
- Python IMDbPY – Default info of Person object
- Python IMDbPY – Searching a person
- Python IMDbPY – Getting Person name from searched name
- Python IMDbPY – Getting person ID from searched persons
- Python IMDbPY – Info set to keys of Person object
- Python IMDbPY – Getting birth date of person
- Python IMDbPY - Checking if person is part of movie or not
- Python IMDbPY - Getting birth place of person
- Python IMDbPY - Getting IMDb index of person
- Python IMDbPY - Getting alternate names of person
- Python IMDbPY – Getting role of person in the movie
- Python IMDbPY - Getting image(head-shot) of person
- Python IMDbPY – Getting Series Countries as XML
- Python IMDbPY – Getting Series Run times as XML
- Python IMDbPY – Getting Series Genres as XML
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

