Forum Discussion

Dhivya_Aroma1's avatar
Dhivya_Aroma1
New Contributor III
6 years ago
Solved

Convert xml attribute to xml element in Snaplogic

Team,

I am looking for a solution in snaplogic to convert the xml attribute to xml element.

My xml looks like this,

Bloodroot Columbine

Thanks,
Dhivya Aroma

6 Replies

    • Dhivya_Aroma1's avatar
      Dhivya_Aroma1
      New Contributor III

      Hi KoryKnick,

      Thanks for the solution. This worked. I understand that xsd is mandatory for the transformation.

      Regards,
      Dhivya.

  • Dhivya_Aroma1's avatar
    Dhivya_Aroma1
    New Contributor III

    Sorry. Only values are pasted and not the tags.

    <catalog>
    <plant botanical="Sanguinaria canadensis" zone="4" light="Mostly Shady">Bloodroot</plant>
    <plant botanical="Aquilegia canadensis" zone="3" light="Mostly Shady">Columbine</plant>
    </catalog>
    
  • Thank you for providing your input. Can you also provide an example of your desired output?

    • Dhivya_Aroma1's avatar
      Dhivya_Aroma1
      New Contributor III

      This is the expected result

      <catalog>
          <plant>
              <botanical>Sanguinaria canadensis</botanical>
              <zone>4</zone>
              <light>Mostly Shady</light>
              <plantValue>Bloodroot</plantValue>
          </plant>
          <plant>
              <botanical>Aquilegia canadensis</botanical>
              <zone>3</zone>
              <light>Mostly Shady</light>
              <plantValue>Columbine</plantValue>
          </plant>
      </catalog>
      

      Once all the attributes are converted to element the final value of plant (i.e., Columbine) needs the new tag name, like here, I have provided plantValue.