question

royjuventus29 avatar image
0 Likes"
royjuventus29 asked royjuventus29 commented

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

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;
FlexSim 22.2.4
flexsim script
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered royjuventus29 commented

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");
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

royjuventus29 avatar image royjuventus29 commented ·

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 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ royjuventus29 commented ·

The XML API was only added in version 23.1.

2 Likes 2 ·
royjuventus29 avatar image royjuventus29 Jason Lightfoot ♦ commented ·
Yes, you are right, this is a matter of software version. Thank you very much!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.