Will not publish to pdf

75 views (last 30 days)
Kevin Castillo Balcaceres
Kevin Castillo Balcaceres on 29 Aug 2021
Answered: Shanmukha Voggu on 1 Sep 2021
Error reported by XML parser: An invalid XML character (Unicode: 0x1a) was found in the element content of the document.
Error using publish
.m file must contain valid XML 1.0 Standard characters.
Error in mdbpublish (line 54)
outputPath = publish(file, options);
Error using open (line 52)
File or variable name must be a character vector or string scalar.
My file name does not have any spaces and neither do any of the names of the path. I am unsure what is causing this.

Answers (1)

Shanmukha Voggu
Shanmukha Voggu on 1 Sep 2021
Hi Kevin,
It is likely there is a special character somewhere in your file. If you are able to run the file without any issues, it is likely somewhere in the comments.
Attached is an example of an M file with a special character in its comments.
If you cannot find a special character in your file, another thing to check would be any places where "char" is called on a number. The way "char" function works is to create unicode commands of the numbers, so this is an easy way to generate invalid XML characters. For example:
ans = ''
For converting numbers to characters it is recommended to use "num2str" instead of "char":
ans = '20'




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!