How to use the XML-related functions provided by the flexsim script help

How to use the XML-related functions provided by the flexsim script help

jiaqzhao
Not applicable
11 Views
4 Replies
Message 1 of 5

How to use the XML-related functions provided by the flexsim script help

jiaqzhao
Not applicable

[ FlexSim 22.2.4 ]

Hello, I have found out that there are some XML functions in the help documentation of flexsim. such as below, I have put them into my script, but it generates an error as it cannot be recognized during the debugging, do I need to declare something at the beginning of my script? Thank you!

XML.Document doc = XML.loadFile("test.xml");
XML.Element root = doc.root;
XML.Element element = root.first;
0 Likes
Accepted solutions (1)
12 Views
4 Replies
Replies (4)
Message 2 of 5

JordanLJohnson
Autodesk
Autodesk
Accepted solution

My guess is you need to specify an absolute path to the file you want to open. If the xml file is in the same directory as the model, I would use the modeldir() command:

XML.Document doc = XML.loadFile(modeldir() + "test.xml");
.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 5

jiaqzhao
Not applicable

Thank you for your answer. I already used the absolute path, and the error is "Unknown type XML.Document in declaration of variable doc". It seems the software does not understand the meaning of "XML.Document". Do you know how to make the function understood by the software?

0 Likes
Message 4 of 5

jason_lightfootVL7B4
Autodesk
Autodesk

The XML API was only added in version 23.1.

Message 5 of 5

jiaqzhao
Not applicable
Yes, you are right, this is a matter of software version. Thank you very much!
0 Likes