Mapping elements names and their values
Create a map to extract XML element names and values.
About this task
In this example, you want to map the previously created XML structure to get a JSON output containing the XML element names and their values in the key and value elements, respectively.
Procedure
Results
{
    "elements": [
        {
            "key": "book",
            "value": [
                {
                    "key": "title",
                    "value": "Pride and Prejudice"
                },
                {
                    "key": "author",
                    "value": "Jane Austen"
                },
                {
                    "key": "isbn",
                    "value": "978-0141439518"
                }
            ]
        },
        {
            "key": "book",
            "value": [
                {
                    "key": "title",
                    "value": "Jane Eyre"
                },
                {
                    "key": "author",
                    "value": "Charlotte Bronte"
                },
                {
                    "key": "isbn",
                    "value": "978-0553211405"
                }
            ]
        }
    ]
}You
				can switch to the other sample and click Test Run again to
				get the following
				result:
         
      {
    "elements": [
        {
            "key": "dvd",
            "value": [
                {
                    "key": "title",
                    "value": "Selma"
                },
                {
                    "key": "director",
                    "value": "Ava DuVernay"
                },
                {
                    "key": "released",
                    "value": "2014"
                }
            ]
        },
        {
            "key": "dvd",
            "value": [
                {
                    "key": "title",
                    "value": "The Hurt Locker"
                },
                {
                    "key": "director",
                    "value": "Kathryn Bigelow"
                },
                {
                    "key": "released",
                    "value": "2008"
                }
            ]
        }
    ]
} 
                     
                    