I have a text file containing a YAML object with repeated keys that I have generated by accessing remote servers.
---
response:
  data:
    configElement:
      elementType: steering-pool
      attribute:
        name: ip-address
        value: 10.10.10.1
      attribute:
        name: start-port
        value: 100
      attribute:
        name: end-port
        value: 9000
      attribute:
        name: realm-id
        value: TSTore
      attribute:
        name: network-interface
        value: M10:150
      attribute:
        name: last-modified-by
        value: admin@10.10.10.10
      attribute:
        name: last-modified-date
        value: 2018-01-23 10:11
    configElement:
      elementType: steering-pool
      attribute:
        name: ip-address
        value: 10.10.10.2
      attribute:
        name: start-port
        value: 1000
      attribute:
        name: end-port
        value: 6535
      attribute:
        name: realm-id
        value: TSTLAN
      attribute:
        name: network-interface
        value: M10:278
      attribute:
        name: last-modified-by
        value: admin@10.10.10.10
      attribute:
        name: last-modified-date
        value: 2010-01-07 11:28
    configElement:
      elementType: steering-pool
      attribute:
        name: ip-address
        value: 10.10.10.3
      attribute:
        name: start-port
        value: 8000
      attribute:
        name: end-port
        value: 9535
      attribute:
        name: realm-id
        value: TestLab2
      attribute:
        name: network-interface
        value: M10:332
      attribute:
        name: last-modified-by
        value: admin@10.10.10.10
      attribute:
        name: last-modified-date
        value: 2009-02-10 12:14
    configElement:
      elementType: steering-pool
      attribute:
        name: ip-address
        value: 10.10.10.5
      attribute:
        name: start-port
        value: 100
      attribute:
        name: end-port
        value: 435
      attribute:
        name: realm-id
        value: NEWLA15
      attribute:
        name: network-interface
        value: M10:253
      attribute:
        name: last-modified-by
        value: admin@10.10.10.10
      attribute:
        name: last-modified-date
        value: 2016-02-22 17:32
    configElement:
      elementType: steering-pool
      attribute:
        name: ip-address
        value: 10.10.10.4
      attribute:
        name: start-port
        value: 100
      attribute:
        name: end-port
        value: 655
      attribute:
        name: realm-id
        value: LAN325
      attribute:
        name: network-interface
        value: M10:2153
      attribute:
        name: last-modified-by
        value: admin@10.10.10.10
      attribute:
        name: last-modified-date
        value: 2019-04-20 13:12
  messages:
  links:
I am struggling to put the data into lines based on its structure. It has multiple elements under a tag configElement.
Using shell script, I want to write data into lines and each line contains data of configElement.
I have already tried solutio proposed on https://stackoverflow.com/a/21189044/8763301, but it didn't fit the format used in my text data.
The expected output is like below, putting all values together from configElement:
attribute: 10.10.10.1,100,9000,TSTore,M10:150,admin@10.10.10.10,"2018-01-23 10:11"
.
.
.
attribute: 10.10.10.2,1000,6535,TSTLAN,M10:278,admin@10.10.10.10,"2010-01-07 11:28"
Please help.
Thanks in advance.
 
     
    