Change xml declaration

Questions about XML that are not covered by the other forums should go here.
panar444
Posts: 2
Joined: Mon Mar 14, 2022 1:34 am

Change xml declaration

Post by panar444 »

Hi, I am new in xml editing!!

I am currently modifing multiple xml files coming from ECG MUSE system. When I recieved these files, they were not only unidentified but the first 2 lines (declaration) was altered also. See below:

<?xml version="1.0"?>
<RestingECG>
<MuseInfo>
<MuseVersion>9.0.4.16760</MuseVersion>
</MuseInfo>
<PatientDemographics>....etc

Instead of:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE RestingECG SYSTEM "restecg.dtd">
<RestingECG>
<MuseInfo>
<MuseVersion>9.0.4.16760</MuseVersion>
</MuseInfo>
<PatientDemographics>.....etc

How can I correct the xml files with OXYGEN editor? I must do this in ca 1500 files, so to open each file in an editor in going to take a lot of time!!

Thank you in advance
PArvanitis
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Change xml declaration

Post by Radu »

Hi,

If the XML files have this heading:

Code: Select all

<?xml version="1.0"?>
this means they specify no encoding and the default XML encoding is "UTF-8" which is a better and more flexible encoding than ""ISO-8859-1"". So in my opinion it is not worth specifying the encoding in all XML files to be "ISO-8859-1". Maybe you can google for "utf-8 versus ISO-8859-1". UTF-8 can express a wider character range (for example Japanese, Chinese) than "ISO-8859-1" which is mostly suited for European languages.
If you still want to perform the initial task, you can use the Oxygen main menu "Find->Find/Replace in Files" dialog to search in your specific folder for

Code: Select all

<?xml version="1.0"?>
and replace with

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
or better yet with

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
panar444
Posts: 2
Joined: Mon Mar 14, 2022 1:34 am

Re: Change xml declaration

Post by panar444 »

Thanks a lot Radu
Regards
Panagiotis
Post Reply