Author Topic: CSV to XML  (Read 602 times)

thope@ozemail.com.au

  • Newbie
  • *
  • Posts: 3
CSV to XML
« on: April 08, 2019, 07:01:46 AM »
Hi All,

I am trying to write a javascript that can be run in Archi, to directly input and change values in the model's XML.
I am not sure if such a feat is possible within Archi and was hoping someone could tell me, or suggest an alternative.
I've been looking at using JQuery to write from CSV into XML but i believe this does not work in Archi.

The larger scope is: I have a csv File that I wish to read data from, take specific data from the csv file and write it into an existing model on Archi.

Cheers,
Roman

Phil Beauvoir

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1502
  • Archi Guy
    • Archi
Re: CSV to XML
« Reply #1 on: April 08, 2019, 08:51:44 AM »
I think you have two options, depending on the form of data you have.

(1) You can import and update a model with csv if the csv is in the correct csv format. So you would need to get your csv data into this format. More details in the Archi User Guide.

(2) It's also possible to update/modify a model using jArchi. This would entail writing a script in JavaScript to (a) read the csv file (b) parse it (c) cherry pick the data and modify a model with this data.

Phil
« Last Edit: April 08, 2019, 16:10:23 PM by Phil Beauvoir »
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 648
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: CSV to XML
« Reply #2 on: April 08, 2019, 19:08:08 PM »
Hi,

Here is an example using jArchi: https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d

Regards,

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

thope@ozemail.com.au

  • Newbie
  • *
  • Posts: 3
Re: CSV to XML
« Reply #3 on: April 10, 2019, 02:00:24 AM »
Thank you for all your replies,

I have been looking at option two from Phil, as it seems to be more closely aligned with what i've been trying to do.
I've looked into the example given by JB, where the user looks like its using papa parse to extract from a csv into a new csv file format,
which is half of what I need. However, I', still unsure if I can inject the extracted csv data into an existing model's XML.

I guess my question is, how do I modify a model's XML using javascript.

Cheers,
Roman

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 648
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: CSV to XML
« Reply #4 on: April 10, 2019, 06:48:39 AM »
Hi,

You do not modify le XML, you edit the model itself in memory using jArchi's API (or through CSV import). Then you simply generate your report. In this (automated) process no XML file is created because you never save the model in the native format.

Regards

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

Stanley

  • Member
  • **
  • Posts: 19
Re: CSV to XML
« Reply #5 on: September 17, 2019, 23:03:20 PM »
Hi

Is there a way to massively update and delete elements and its relationships in a waterfall way with jArchi on the XML?

Best regards,

Jean-Baptiste Sarrodie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 648
  • Archi Evangelist and Contributor. Visionary.
    • About me...
Re: CSV to XML
« Reply #6 on: September 18, 2019, 06:50:25 AM »
Hi,

You can do almost whatever you want with jArchi. You can have a look at its API: https://github.com/archimatetool/archi-scripting-plugin/wiki

Regards,

JB
If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate