Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to import an XML file into illustrator?

New Here ,
Aug 06, 2019 Aug 06, 2019

The client has provide me his own color palette in .XML format, I don't know how to import these colors or is there any other options to import into illustrator.

Please help me resolve this issue.

Moderator: Moved from Adobe Creative Cloud to Illustrator

TOPICS
Scripting
8.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Aug 06, 2019 Aug 06, 2019

There is no such functionality. You would need to create a script that converts the values to ASE or whatever so they can be imported into the color palette.

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2019 Aug 07, 2019

You could try if any other CC app can make anything out of the XML and then create swatches from there and put them into the CC libraries to transfer them to Illustrator.

I would try Dreamweaver or XD (and maybe take a look at XD plugins if it still doesn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 07, 2019 Aug 07, 2019

Hi Praveen,

I agree with Mylenium, there is no way of doing this directly in Illustrator, however, it might be possible through scripting. Hence, I am moving this discussion to Illustrator Scripting community, so that you can get some more responses from our scripting experts.

You can also check out some suggestions shared on this similar discussion : Importing Color to Swatch Library from Text File​ and see if that works.

Regards,

Srishti

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2019 Aug 07, 2019

The XML file should be using colors that are valid under html. Those colors should be easily duplicated in the AI or PS color pallets. There are fields for pretty much all of them built in.

For example...

"background-color: rgb(52,0,246);"

....is simply...

R: 52
G: 0
B: 246

...in AI's color pallet and...

"color: #3400f6;"


..is just 3400f6 in the # field on the bottom of the color pallet.

If you need help discerning what the colors are in the code, post it here and I should be able to separate them out pretty easily for you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2019 Aug 07, 2019

Can you show pice of your XML?

Here is an example code, Work with XML.

var colour =

<root>

   <color id="clr1">

      <cyan>80</cyan>

      <magenta>30</magenta>

      <yellow>0</yellow>

      <black>0</black>

   </color>

   <color id="clr2">

      <cyan>80</cyan>

      <magenta>30</magenta>

      <yellow>0</yellow>

      <black>0</black>

   </color>

</root>;

var xml = new XML(colour);

var clr = new CMYKColor();

clr.cyan = Number(xml.color.(@id=="clr1").cyan);

clr.magenta = Number(xml.color.(@id=="clr1").magenta);

clr.yellow = Number(xml.color.(@id=="clr1").yellow);

clr.black = Number(xml.color.(@id=="clr1").black);

var newSwatch = app.activeDocument.swatches.add();

newSwatch.color = clr;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2019 Aug 08, 2019

There's gotta be more to the code than that, isn't there?

Right now, they only have code for one color (even though they create ids for two)

CMYK: 80, 30, 0, 0

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 08, 2019 Aug 08, 2019

Yeah, this code creates only one color, if you want to add more, the best shot will be to close this in a for loop.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2019 Aug 08, 2019

Oops, nevermind, I mistook Ten A for the original poster.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2019 Aug 08, 2019
LATEST

No problem, Jon. (^_^)/

I added more detail, How to determine loop length and do looping.

However, It's necessary to know XML structure when we read it and processing children.

var colour =

<root>

   <color id="clr1">

      <cyan>80</cyan>

      <magenta>30</magenta>

      <yellow>0</yellow>

      <black>0</black>

   </color>

   <color id="clr2">

      <cyan>50</cyan>

      <magenta>0</magenta>

      <yellow>100</yellow>

      <black>0</black>

   </color>

   <color id="clr3">

      <cyan>0</cyan>

      <magenta>50</magenta>

      <yellow>100</yellow>

      <black>0</black>

   </color>

   <color id="clr4">

      <cyan>00</cyan>

      <magenta>40</magenta>

      <yellow>20</yellow>

      <black>35</black>

   </color>

   <color id="clr5">

      <cyan>0</cyan>

      <magenta>0</magenta>

      <yellow>50</yellow>

      <black>50</black>

   </color>

</root>;

var xml = new XML(colour);

var num = xml.children().length();

var clr, newSwatch;

for (var i=0;i<num;i++){

clr = new CMYKColor();

clr.cyan = Number(xml.children().cyan);

clr.magenta = Number(xml.children().magenta);

clr.yellow = Number(xml.children().yellow);

clr.black = Number(xml.children().black);

newSwatch = app.activeDocument.swatches.add();

newSwatch.color = clr;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines