Hello all. I’m a total newby so please bear with me. i have this xml file which has been parsed and I’m using xmltodict here is the file.
here is the xml
Explanation: The print tells you how to construct the values. The outer braces [] tell me it is a list. The list has one item, numbered 0. That one item is a dictionary, the braces being {}.
So the IP is found by first indexing with zero (the first item in the list) and then “ip”, the key of the ip-number.
xml and json are text formats, so you can paste these as formatted text without pretty printing. Please do so, because I had to “fix” the format to be able to use the texts. Also the shouting (all caps text) is generally considered overkill, please don’t.
Hello and thanks for your help. Apologies for the caps, point noted. the reason for the pprint is i’m follwing a learning exercise and this is what they use.
What i’m actually trying to achieve is a single query from the xml that gives the answer as
test1
172.16.0.2 255.255.255.0 ?
How do i achieve this please?
I do not understand your problem. You know how to get the individual elements, what is stopping you from putting these in order to get the desired result?
I was trying to apply the same logic to show me how to get an ip address and a subnet mask on the same line
test1
‘172.16.0.2 255.255.255.0’
i dont want to run two print commands i want to use one name, in this case test1 to show my the ip and subnet mask without the brackets. How or is this possible please?
Than you need to have one variable, containing the string ‘172.16.0.2 255.255.255.0’. You can create it in several ways, it is just string handling. What did you try and how did it fail?