Cisco
300-535 · Question #54
Refer to the exhibit. Using the provided XML snippet, which Xpath expression prints "Jane"?
The correct answer is C. //employee[1]/firstName/text(). Xpath has a index number starting from 1, and I have run the snippet using lxml in python confirms index 1 is correct: from lxml import etree html = etree.parse('employee.html') print type(html) result = html.xpath('//employee[1]/firstName/text()') <type 'lxml.etree._ElementTree'
Design for Cisco Cloud Automation
Question
Refer to the exhibit. Using the provided XML snippet, which Xpath expression prints "Jane"?
Exhibit
Options
- A//employee[1]/firstName/value()
- B//employee[0]/firstName/value()
- C//employee[1]/firstName/text()
- D//employee[0]/firstName/text()
How the community answered
(60 responses)- A15% (9)
- B7% (4)
- C75% (45)
- D3% (2)
Explanation
Xpath has a index number starting from 1, and I have run the snippet using lxml in python confirms index 1 is correct: from lxml import etree html = etree.parse('employee.html') print type(html) result = html.xpath('//employee[1]/firstName/text()') <type 'lxml.etree._ElementTree'>
Topics
#XPath#XML#YANG#data retrieval
Community Discussion
No community discussion yet for this question.
