Hi,
Hopefully the following might help to demonstrate.
In this example the entire configuration has been retrieved from the device, and using the xpath() method just a subset of that data has been output (part of the global address-book in this scenario).
from jnpr.junos import Device
from lxml import etree
dev = Device(host='x.x.x.x', user='foo', passwd='bar')
dev.open()
data = dev.rpc.get_config()
output = data.xpath('/rpc-reply/configuration/security/address-book[name="global"]/address[name="MySlashTwenty"]')
print etree.tostring(output[0])
An alternate approach could also be to only retrieve a subset of the data from the device instead of everything,
from jnpr.junos import Device
from lxml import etree
from lxml.builder import E
dev = Device(host='x.x.x.x', user='foo', passwd='bar')
dev.open()
filter = E('security', E('address-book', E('name', 'global'), E('address', E('name','GoogleDNS'))))
data = dev.rpc.get_config(filter)
output = data.xpath('/rpc-reply/configuration')
print etree.tostring(output[0])
The results produced for each scenario are as shown below:
Example 1:
<address>
<name>MySlashTwenty</name>
<ip-prefix>10.142.96.0/20</ip-prefix>
</address>
Example 2:
<configuration changed-seconds="1453826277" changed-localtime="2016-01-26 16:37:57 UTC">
<security>
<address-book>
<name>global</name>
<address>
<name>GoogleDNS</name>
<ip-prefix>4.4.4.4/32</ip-prefix>
</address>
</address-book>
</security>
</configuration>
I have to admit, that I normally develop scripts in SLAX and my Python is far from great, and there could of course be better ways to perform this...
Regards,
Andy