Data360 Analyze

 View Only
  • 1.  XML Files Containing Both Data and Images

    Posted 23 days ago

    Hi Support

    I was wondering if D360 can convert XML files that contain both data and images?

    I just seem to see a node for XML data..

    Looking forward to your reply



    ------------------------------
    andrew darnell
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: XML Files Containing Both Data and Images

    Posted 15 days ago

    There are many many rabbit holes which one can go down with this topic. However, my opinion is that the best approach for XML and binary data would be to base64 encode a binary element. With this approach it is simply standard XML being transmitted.



    ------------------------------
    Peter Sykes
    Data Governance & Architecture
    Vontobel Holding AG
    Zurich
    ------------------------------



  • 3.  RE: XML Files Containing Both Data and Images

    Employee
    Posted 15 days ago
    Edited by Adrian Williams 15 days ago

    Just to continue the comments by Peter, if you have source XML files that contain image data then, the binary image data must already have been encoded using, say, base64 as XML is a specification for documents that store textual information, though it can contain links to other resources (files, URLs, etc) that may relate to binary data.

    Data fields in Data360 Analyze cannot contain binary data so, to handle binary data in Data360 Analyze you would need to ensure the data is encoded. You can leverage Python functions in a Transform node to decode, for example using the following in the ProcessRecords Script of a Transform node (changing the paths as required) :


    ## Specify the path of the source image data file
    infile = r"<Path_to_Source_image.png>"

    with open(infile, 'rb') as input_file:
      binData = input_file.read()

    ## Encode the binary data to base64
    encoded64 = binData.encode("base64")

    ## Clean up as the binary data is no longer required
    binData = None

    ####

    ## Do something here, then (possibly in another Transform node)

    #### 

    ## Import the module here if using a different node to write the data
    # import base64

    ## Specify the output file
    outFile = r"<Path_to_Destination_image.png>"

    ## Decode the base64 data to binary
    decodedData = base64.b64decode(encoded64)

    ## Write the binary data to the file
    with open(outFile, 'wb') as f:
      f.write(decodedData)



    ------------------------------
    Adrian Williams
    Precisely Software Inc.
    ------------------------------