Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3399

Get data container from XML

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Open
    • Priority: (None)
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      It would be nice if we could read XML into a data container.

      Currently, we can read json, yaml, CSV and ENV formats into a data container.

      I think it would be nice to have functions for

      • parsexml
      • readxml

      Also, it would be nice if readdata suppoorted xml for auto

       

      XML like the following:

      <?xml version="1.0" encoding="UTF-8" ?>
      <employees>
      	<employee>
      		<id>1</id>
      		<firstName>Leonardo</firstName>
      		<lastName>DiCaprio</lastName>
      		<photo>http://1.bp.blogspot.com/-zvS_6Q1IzR8/T5l6qvnRmcI/AAAAAAAABcc/HXO7HDEJKo0/s200/Leonardo+Dicaprio7.jpg</photo>
      	</employee>
      	<employee>
      		<id>2</id>
      		<firstName>Johnny</firstName>
      		<lastName>Depp</lastName>
      		<photo>http://4.bp.blogspot.com/_xR71w9-qx9E/SrAz--pu0MI/AAAAAAAAC38/2ZP28rVEFKc/s200/johnny-depp-pirates.jpg</photo>
      	</employee>
      	<employee>
      		<id>3</id>
      		<firstName>Hritik</firstName>
      		<lastName>Roshan</lastName>
      		<photo>http://thewallmachine.com/files/1411921557.jpg</photo>
      	</employee>
      </employees>  
       

      Could be converted into JSON like this:

      {
      	"employees": {
      		"employee": [
      			{
      				"id": "1",
      				"firstName": "Leonardo",
      				"lastName": "DiCaprio",
      				"photo": "http://1.bp.blogspot.com/-zvS_6Q1IzR8/T5l6qvnRmcI/AAAAAAAABcc/HXO7HDEJKo0/s200/Leonardo+Dicaprio7.jpg"
      			},
      			{
      				"id": "2",
      				"firstName": "Johnny",
      				"lastName": "Depp",
      				"photo": "http://4.bp.blogspot.com/_xR71w9-qx9E/SrAz--pu0MI/AAAAAAAAC38/2ZP28rVEFKc/s200/johnny-depp-pirates.jpg"
      			},
      			{
      				"id": "3",
      				"firstName": "Hritik",
      				"lastName": "Roshan",
      				"photo": "http://thewallmachine.com/files/1411921557.jpg"
      			}
      		]
      	}
      }
      

      https://codebeautify.org/xmltojson#

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              a10042 Nick Anderson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel