cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to create XML files on local directory

Yoshihiko.N
14-Alexandrite

How to create XML files on local directory

Dear all developers,

I would like to know how to create xml files on local directory like my desktop and I created test code below but it doesn't work. 
Could you kindly let me know how to achieve?
 
================my test code is below.(hide username due to privacy) ====================
var languages = new XML( '<languages type="dynamic"><lang>JavaScript</lang> <lang>Python</lang></languages>');
 
var params = {
   path: "C:\Users\username\Desktop\newXMLFoloder\test.xml",
    content: languages 
};
 
// no return
 me.SaveXML(params);
ACCEPTED SOLUTION

Accepted Solutions
VladimirRosu
19-Tanzanite
(To:mnarang)

+1 for Mukul's answer.

We don't allow saving files anywhere outside of the FileRepositories for security reasons.

Even if you use an extension to do this, I would expect for any properly secured system that the user under which Tomcat (and subsequently ThingWorx) runs does not have access to write to those folders.

 

View solution in original post

4 REPLIES 4

saveXML is a snippet under File repository thing. So if you give the path for file repo and content as XML it will save the file as a XML document in your file repository. For example I have a TestRepo thing with template as FileRepository and if I execute this service on the Thing it give me the required xml in TestRepo of ThingWorx.

 

me.SaveXML({
path: "test1.xml" /* STRING */,
content: '<languages type="dynamic"><lang>JavaScript</lang> <lang>Python</lang></languages>' /* XML */
});

 

After executing above I will get test1.xml in root of my TestRepo folder under ThingworxStorage->repository folder.

 

 

Yoshihiko.N
14-Alexandrite
(To:mnarang)

Thank you for your reply but I would like to know how to create xml files on local directory not repository folder.

Thingworx can save different type of files in it's repository but AFAIK there is no OOTB way to save an xml directly into local. You can write a custom Java extension to either write it into your local or pick from Thingworx repository and move it to your desired local location.

 

Thanks,

Mukul Narang

VladimirRosu
19-Tanzanite
(To:mnarang)

+1 for Mukul's answer.

We don't allow saving files anywhere outside of the FileRepositories for security reasons.

Even if you use an extension to do this, I would expect for any properly secured system that the user under which Tomcat (and subsequently ThingWorx) runs does not have access to write to those folders.

 

Announcements


Top Tags