0 Replies Latest reply on Jul 16, 2007 2:17 PM by bike2810

    Reformat XML SOAP Response

    bike2810
      Hi,

      I am creating a CF component that calls a Web service and I would like to reformat the result. I do not have access to the service provider to make changes so I have to make the conversion on the client side.

      The result from the service returns the field definitions for every element then the actual data values follow. Here is an example of the XML sent back from the service only showing two elements.

      <fieldDefinitions>
      <fieldName>NAME1</fieldName>
      <fieldType>STRING</fieldType>
      <fieldLength>20</fieldLength>
      </fieldDefinitions>

      <fieldDefinitions>
      <fieldName>NAME2</fieldName>
      <fieldType>STRING</fieldType>
      <fieldLength>40</fieldLength>
      </fieldDefinitions>

      <dataRows>
      <value>John</value>
      <value>Doe</value>
      </dataRows>

      I would like to reformat the XML to make the value of the <fieldName> as the element tag then put the actual value inside the tag. Something like this.

      <name1>John</name1>
      <name2>Doe</name2>

      I am not exactly sure what the best method would be to accomplish this, using the XmlNew function or maybe transforming the output with a style sheet (XSLT).

      Any suggestions would be helpful.

      Thanks,
      Chris