How to generate a xml document?

I have values which are stored in pv and which are basically xml strings. Now to want to create a xml file and write those data to the file and save it to appian. How can I achieve it?

  Discussion posts and replies are publicly visible

  • Hi Sudip,
    You can achieve this in following ways.

    1) Create a custom CDT with all the necessary properties so it can create xml based on that CDT use toXML(). I think you might have heard of this.

    2) If you want to create complex xml then you can use the custom plugin to achieve this.

    I think the first one gives you the best results compare to the second one until you need to create simple XML. I hope this will help.

  • I have a complex xml. Can you refer a custom plug in to achieve this?
  • Hello sudiptav

    How complex is your XML? The CDT itself is an XSD so I think you can still use it in a complex scenario. Can you describe how complex is your XML? To fill this cdt with data you can have multiple for each in a rule transforming the “table cdt” to the “xml cdt”

    To create a complex CDT you can follow the Antipattern used of the CDTs used in the ones that write to the database. Specifically to give an example you can have nested a lot of levels.

    database CDT (we prefer flat version, as possible, at least they a view)
    <person>
    <name>
    <lastName>
    <birthdate>
    <addressStreet>
    <addressZupCode>
    <address...>
    <phone1type>
    <phone1countryCode>



    XML CDT(here you can add multiple layers and maybe even reuse the original cdt
    <root>
    <persons>
    <person>
    <personId>
    <status>
    <statusId>
    <birthdate >
    <birthdateFormated >
    <name>...
    <lastName>...
    <address>
    <street>..
    <zipCode>
    </address>
    <phones>
    <phone>
    <phoneType>
    <number>
    <countryCode>
    ....

    notes:
    * when I have to make this I prefer to create almost a new version of the cdt to include the labels, IDs and the formatted version of the information.
    * When calling the toxml function you define the namespace or you can define one empty.

    Even if you have any other special requirement you can still “modify a little the xml as text”.

    So my question is, what is the actual structure you want to achieve ? How complex is it?

    To give you a concrete example of this situation when you import a WSDL the xml structure can be really complex and we still able to call it.

    I hope this helps.

    Jose