Will not publish to pdf

20 次查看(过去 30 天)
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.

回答(1 个)

Shanmukha Voggu
Shanmukha Voggu 2021-9-1
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:
char(20)
ans = ''
For converting numbers to characters it is recommended to use "num2str" instead of "char":
num2str(20)
ans = '20'

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by