How to create XML from data

Hi, Can anyone send me a knime example that can do this:

  1. data read , a select query from table and generate some result–done.
  2. put in XML, this XML need to be exact format that my customer need. So basically, the customer send me the XML format, and I need to fill in with my order data .
    Can Knime do that?
    I tried with data reader–Table to Json–Json to XML–XML writer. It does generated XML file, but not in the format the customer need .

Is there a way in Knime that can read the customer xml, then put value in, then generate same format XML?


1 Like

Hi @fanrf,

Will you be able to provide an example workflow of your partial solution? A toy dataset will do fine.

Can you also share the structure/formal of the XML that you want to populate with the data? This is important to answer your question.


1 Like

Thanks for the response.
So far I didn’t make too much progress. I can only find column to XML in knime and that didn’t help much.
The whole purpose is read data from Sql serve table, like a sales invoice infor, and fill in the XML like below.

<?xml version="1.0" encoding="UTF-8"?>

  <Credential domain="Dom1">





  <Credential domain="Dom2">





  <Credential domain="Dom3">




  <UserAgent>Your Very Own Agent 1.23</UserAgent>


  <InvoiceDetailRequestHeader invoiceID="CD24706_882015_8" purpose="standard" operation="new" invoiceDate="2015-04-30T11:45:51-07:00">

    <InvoiceDetailHeaderIndicator />

    <InvoiceDetailLineIndicator isAccountingInLine="yes" />


      <Contact role="remitTo" addressID="RTCode">

        <Name xml:lang="en">RTName</Name>




      <Contact role="billTo">

        <Name xml:lang="en">xxx yyy</Name>

        <PostalAddress name="default">






          <Country isoCountryCode="BE">1</Country>


        <Email name="default"></Email>

        <Phone name="work">


            <CountryCode isoCountryCode="BE">Belgium</CountryCode>


            <Number>+1 (987) 654-3210</Number>





    <PaymentTerm payInNumberOfDays="30" />





        <!-- payloadID is the Contract number -->

        <DocumentReference payloadID="441" />



    <!-- First invoice quantity line. -->

    <InvoiceDetailItem invoiceLineNumber="1" quantity="1">


        <Money currency="USD">100</Money>


      <InvoiceDetailItemReference lineNumber="1">

        <Description xml:lang="en">Item01</Description>



        <Money currency="USD">100</Money>






      <Money currency="USD">100</Money>



      <Money currency="USD" alternateAmount="10" alternateCurrency="EUR">8</Money>

      <Description xml:lang="en">total tax</Description>

      <TaxDetail purpose="tax" category="Standard Rate" percentageRate="20" taxPointDate="2014-06-30T11:45:51-07:00">


          <Money currency="USD">100</Money>



          <Money currency="USD">20</Money>


        <TaxLocation xml:lang="en">CA</TaxLocation>




      <Money currency="USD" />



1 Like

Yes the Column To XML node is a good starting point. There is also the XML Row Combiner Node which allows you to do combine XML elements under a parent element.

Have a look at this example workflow from the KNIME Hub. It shows how create XML elements, combine them and also insert attributes. This should cover the basics.

Hope this helps!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.