eXtensible Markup Language :Using Python to Access Web Data (Python for Everybody Specialization) Answers 2025
1
What is the name of the Python 2.x library to parse XML data?
✅ xml.etree.ElementTree
❌ xml-misc
❌ xml.json
❌ xml2
Explanation: xml.etree.ElementTree is the standard Python library for parsing XML (available in Python 2.x and 3.x).
2
What is the method to cause Python to parse XML that is stored in a string?
✅ fromstring()
❌ parse()
❌ readall()
❌ extract()
❌ xpath()
Explanation: xml.etree.ElementTree.fromstring() parses XML from a string; parse() reads from a file/stream.
3
In this XML, which are the “complex elements”?
✅ person
❌ phone
❌ name
❌ Noah
❌ people
Explanation: A complex element is an element that contains other elements (children). <person> contains <name> and <phone>, so person is the complex element here. (people is a container too but the common teaching example focuses on person as the complex element containing children.)
4
In the following XML, which are attributes?
❌ email
✅ type
❌ name
✅ hide
❌ person
Explanation: type="intl" and hide="yes" are attributes on elements (phone and email). email, name, person are element names, not attributes.
5
Which node is the parent node of node e?
❌ a
✅ c
❌ e
❌ b
Explanation: The direct parent of <e> is <c>.
6
What text value would we find at path /a/c/e?
❌ Y
✅ Z
❌ e
❌ a
❌ b
Explanation: /a/c/e selects the <e> element, whose text is Z.
7
What is the purpose of XML Schema?
❌ A Python program to transform XML files
❌ To transfer XML data reliably during network outages
❌ To compute SHA1 checksums on data
✅ To establish a contract as to what is valid XML
Explanation: XML Schema (XSD) defines the expected structure/types of XML documents — a contract for validity.
8
Given the schema and XML snippet, which tag is incorrect?
Schema expects <age> (lowercase integer); XML has <Age>17</Age>.
❌ lastname
❌ person
❌ dateborn
❌ age
✅ Age
Explanation: Tag names are case-sensitive in XML vs the schema — Age (capital A) does not match age in the schema.
9
What is a good time zone to use when computers are exchanging data over APIs?
❌ Local time of sending computer
❌ Local time of receiving computer
✅ Universal Time / GMT
❌ Local time of sending computer without DST
Explanation: Use UTC (ISO standard) to avoid ambiguity across systems and DST issues.
10
Which of the following dates is in ISO8601 format?
✅ 2002-05-30T09:30:10Z
❌ 2002-May-30
❌ May 30, 2002
❌ 05/30/2002
Explanation: YYYY-MM-DDThh:mm:ssZ is ISO 8601 (UTC indicated by Z).
🧾 Summary Table
| Q | Correct Answer(s) | Key concept |
|---|---|---|
| 1 | xml.etree.ElementTree |
Standard XML parsing library |
| 2 | fromstring() |
Parse XML from a string |
| 3 | person |
Complex element contains child elements |
| 4 | type, hide |
Element attributes |
| 5 | c |
Parent of <e> |
| 6 | Z |
Text at /a/c/e |
| 7 | Establish valid XML contract | Purpose of XSD |
| 8 | Age (incorrect) |
Tag case must match schema |
| 9 | UTC / GMT | Use UTC for APIs |
| 10 | 2002-05-30T09:30:10Z |
ISO 8601 format |