Parsing Junos commands using parse_xml
In this recipe, you will learn how to parse XML data into JSON. Unlike previous examples, where we used from_xml to translate the data into native Python data structures, this recipe will show an alternative way of parsing XML into JSON, with the added flexibility of providing your own specification file.
- Create a playbook called
pb_get_bgp.ymlto get the BGP neighbor state:root@cookbook-lab:~/cookbook-lab/chapters/ch05# vi pb_get_bgp.yml --- - name: “Collect BGP and Parse XML with parse_xml” hosts: “juniper_crpd” tasks: - name: “Collect BGP Neighbors” junipernetworks.junos.junos_command: commands: “show bgp neighbor” display: “...