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

How to make friends with СС2018 and СС2015 when working with XML-files

Participant ,
Apr 13, 2018 Apr 13, 2018

Hello everybody.

in the CC 2015 to read the files I have a script, everything works well

function readXML (file) {//------------------------------------

  try {

    file = File(file)

//    file.encoding = "UTF8";  

//    file.lineFeed = "unix";  

    file.open('r');

    content = file.read();

    file.close();

    return new XML(content);

  } catch (e) {

    alert("" + e.message + "\n Error read from XML " + file );

  }

  return content;

};

function writeXML(file,xml) {//---------------------------------

  try {

    file = File(file)   

  //  file.encoding = "UTF8";      

    file.open("w");

    file.write(xml);

    file.close();

  } catch (e) {

    alert("" + e.message + "\n Error write to XML " );  }

  return true;

};

PS CC2018 read XML file (I control the information from the file by using Alert() ), but if I write to the file back, the file will be empty

If add rows 03,04,19 -  CC2018 worked. But CC2015 not read XML file

TOPICS
Actions and scripting
518
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

correct answers 1 Correct answer

People's Champ , Apr 13, 2018 Apr 13, 2018

I did not check, but try using this version of the write function

function writeXML(file,xml)

  try { 

    file = File(file)     

    file.encoding = "UTF8";        

    file.open("w"); 

    file.write("\uFEFF");

    file.writeln(xml);

    file.close(); 

  } catch (e) { 

    alert("" + e.message + "\n Error write to XML " );  } 

  return true; 

}; 

Translate
Adobe
People's Champ ,
Apr 13, 2018 Apr 13, 2018

I did not check, but try using this version of the write function

function writeXML(file,xml)

  try { 

    file = File(file)     

    file.encoding = "UTF8";        

    file.open("w"); 

    file.write("\uFEFF");

    file.writeln(xml);

    file.close(); 

  } catch (e) { 

    alert("" + e.message + "\n Error write to XML " );  } 

  return true; 

}; 

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
Participant ,
Apr 13, 2018 Apr 13, 2018
LATEST

I'm sorry, at work I have installed CC2017.1 ... I tried your code, it works on both versions of Photoshop (СС2015.1 - СС2017.1). Thank 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