350-401 Automation Practice Question
A network engineer is designing a Python script that uses the YANG models supported by a Cisco IOS XE device to retrieve interface statistics via NETCONF. The engineer wants to ensure the script can parse the response and extract the operational data. Which two steps are necessary when using the ncclient library to retrieve and process the data? (Choose two.)
⚠ Common exam trap
The trap here is thinking that ncclient automatically converts XML to JSON or that <edit-config> can be used for reading data, but NETCONF uses XML and <get> for retrieval.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Parse the XML response using a library like xml.etree.ElementTree or lxml
To retrieve interface statistics via NETCONF, the script must send a <get> RPC with a filter to target the specific data. The response is XML, so parsing it with an XML library is required to extract values. Other options like <edit-config> or :candidate are for configuration management, not data retrieval.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Enable the :candidate capability on the device to retrieve statistics
Why it's wrong here
The :candidate capability is for staging configuration changes, not for retrieving operational data. Statistics are read from the running state, not the candidate datastore. Enabling :candidate is irrelevant for this task and would not help in retrieving interface statistics.
- ✓
Parse the XML response using a library like xml.etree.ElementTree or lxml
Why this is correct
NETCONF returns data in XML format. To extract specific values, the script must parse the XML. Libraries such as xml.etree.ElementTree or lxml allow navigation of the XML tree. This step is necessary to process the response and retrieve the statistics values for further use.
- ✗
Convert the XML response to JSON using the ncclient library
Why it's wrong here
The ncclient library does not automatically convert XML to JSON. It returns the raw XML response. While some tools may offer conversion, ncclient itself does not provide this functionality. The engineer must handle XML parsing manually or use another library for conversion if needed.
- ✓
Use the <get> RPC with a filter specifying the interface statistics subtree
Why this is correct
The <get> RPC is used to retrieve operational data from the device. To limit the response to interface statistics, a filter must be applied. This filter can be expressed in subtree or XPath format, targeting the specific YANG model nodes for interface statistics. This step is essential to obtain the desired data efficiently.
- ✗
Use the <edit-config> RPC to read the interface statistics
Why it's wrong here
<edit-config> is used to modify configuration, not to retrieve operational data. Using it to read statistics would be incorrect and could potentially alter the configuration. The correct RPC for reading data is <get> or <get-config> for configuration data.
Go deeper
Related to this question
About these practice questions
One of 1,923 original 350-401 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Cisco exam blueprint
This 350-401 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 350-401 exam.