nerdexam
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

300-535 question #54 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)
  • A
    15% (9)
  • B
    7% (4)
  • C
    75% (45)
  • D
    3% (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.

Full 300-535 Practice