IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

How to use Documents.NewFileFromText method Options · View
Alexander.Linkov
Posted: Friday, October 21, 2016 3:17:03 PM
Rank: Newbie

Joined: 10/21/2016
Posts: 3
Hello!

I try to create a macros, and stack with using the Documents.NewFileFromText() methods.
I have a plain html source, similar to this:
Code:
<!DOCTYPE html>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Some Title</title>
</head>
<body>
......
</body>
</html>

I want to create a new file with this content by using the:
Code:
Application.Documents.NewFileFromText(htmlcontent, "html");

but I get
Code:
"0x800406a9 - Altova.Application: Documents: Documents: error setting text as xml content"

Even when I try to use:
Code:
Application.Documents.NewFileFromText("text", "txt");

I get the same error.
What am I doing wrong?
underpar
Posted: Monday, October 24, 2016 6:41:21 AM
Rank: Member

Joined: 12/11/2013
Posts: 18
Location: everywhere
This would appear to be a bug and has been logged in the internal bug database

The bug entry number is TTP# 52761

Application.Documents.NewFileFromText method returns an error if the first parameter is not well formed xml (even for non xml file types)


As soon as this issue has been addressed it will appear on our release notes page:

Alexander.Linkov
Posted: Monday, October 24, 2016 7:09:03 AM
Rank: Newbie

Joined: 10/21/2016
Posts: 3
I am looking forward to fix!

Thank you!
underpar
Posted: Monday, October 24, 2016 8:39:42 AM
Rank: Member

Joined: 12/11/2013
Posts: 18
Location: everywhere
Note that the following will work (META tag is closed with forward slash at end of tag) and quotes are prepended with a backslash:

var str = "<!DOCTYPE html><html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/><title>Some Title</title></head><body></body></html>"


Application.Documents.NewFileFromText(str , "html");
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.