I hope my query is simple to respond, but I haven't been able to figure it out. Based on the snippet SAMPLE OUTPUT below, as you can notice under interfaces I could have interfaces <interface-range> or simply <interface> nodes. I want to write a for-each loop that goes down the result and prints the name under the <interface> or <interface-range> in one single run.
I can do a for-each config that checks on one node name at the time (see CODE below), but I want to be able to go down and check and if the node is either <interface> or <interface-range> then to print the <name> node value. In other words I need an OR like checking as part of the for-each statement. Is this possible? I have tried multiple combinations but none have worked.
Can I do something like the CODE DESIRED below for the for-each statement? (this doesn't work, but that's the idea of what I am looking to do)
CODE:
var $config-rpc = <get-configuration>{
<configuration> {
<interfaces> {
}
}
}
var $config = jcs:invoke( $config-rpc );
for-each($config//interfaces/interface) {
<output> "Interface or range: " _ ./name;
}
CODE DESIRED: (this doesn't work, but that's the idea of what I am looking to do)
for-each( ($config//interfaces/interface) || ($config//interfaces/interface-range) ){
<output> "Interface or range: " _ ./name;
}
SAMPLE OUTPUT:
> show configuration interfaces | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.2R1/junos">
<configuration junos:commit-seconds="1363885658" junos:commit-localtime="2013-03-21 13:07:38 EDT" junos:commit-user="root">
<interfaces>
<interface-range>
<name>serverZ_manage_trunk</name>
<member-range>
<name>ge-4/0/35</name>
.....
<interface>
<name>ge-0/0/1</name>
<description>Connection XYZ->A</description>
.....