Link to script article

You need to export a scene or some information to a text file? Some of your data are in a XML file but you don't know how to import them?

Here is a Maxscript library to read and write XML file easily.

This script encapsulates all the DotNet code required to access and modify XML files in a Maxscript structure that can be easily re-used in any other scripts. No DotNet experience is required to use it.

R9 to 2017


All the instructions to install and to use the library are provided within the script archive.

The script file also includes a demo part to describe the main functions of the library and some cases of use.

This is a example of how to use the library in Maxscript:


-- Once the script has been evaluated, we can instanciate the library
-- and create a new XML file

myNewXmlDoc = tXMLDocument()
myNewXmlDoc.mfCreateXML rXmlFilePath:"d:\\temp\\myXmlFile.xml"

-- so far there is no root node, so the value undefined is returned
myRootNode = myNewXmlDoc.mfGetRootNode()

-- we create a root node and get it
-- it is mandatory to create at least one node, the root, to save the file

myRootNode = myNewXmlDoc.mfCreateRootNode "DocRoot"

-- root information are displayed

-- a new node is created, modified and added to the root node
myNodeLevel1 = myNewXmlDoc.mfGetNewNode "NodeLevel1"
myNodeLevel1.mfAddAttribute "name" "FirstNode"
myRootNode.mfAppendChild myNodeLevel1

-- we create another node
myNodeLevel2 = myRootNode.mfGetNewNode "NodeLevel2"
myNodeLevel2.mfSetText "Text in node level 2"
myNodeLevel2.mfAddAttribute "Attribute" "1234"
myNodeLevel2.mfGetAttribute "Attribute"
myNodeLevel2.mfSetAttribute "Attribute" "123456789"
rootNodeChildrenArr[1].mfAppendChild myNodeLevel2

-- the document is saved and released