XML.Node

Description

A base class for other XML Nodes.

Properties

first Get the first child of the node, null if there are no children.
last Get the last child of the node, null if there are no children.
next Get the next sibling of the node, null if there is no next sibling.
prev Get the previous silbing of the node, null if there is no previous sibling.
up Get the parent of the node, null if the current node is a Document.
value Returns the value of the node. The meaning of 'value' changes for the specific type.

Methods

createComment Create an XML.Comment child node.
createDeclaration Create an XML.Declaration child node.
createElement Create an XML.Element child node.
createText Create an XML.Text child node.
createUnknown Create an XML.Unknown child node.
deleteChild Delete a child from this node.
deleteChildren Deletes all children from this node.

Details

Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.first

readonly XML.Node first

Description

Get the first child of the node, null if there are no children.


                XML.Document doc = XML.loadFile("test.xml");
                XML.Declaration dec = doc.first;
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.last

readonly XML.Node last

Description

Get the last child of the node, null if there are no children.


                XML.Document doc = XML.loadFile("test.xml");
                XML.Element element = doc.last;
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.next

readonly XML.Node next

Description

Get the next sibling of the node, null if there is no next sibling.

This example code loops through each child of the root node and prints its value.

                XML.Document doc = XML.loadFile("test.xml");
                XML.Element root = doc.root;
                XML.Element element = root.first;
                while (element) {
                    print("value:", element.value);
                    element = element.next;
                }
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.prev

readonly XML.Node prev

Description

Get the previous silbing of the node, null if there is no previous sibling.


                XML.Document doc = XML.loadFile("test.xml");
                XML.Element root = doc.root;
                XML.Element element = root.last;
                XML.Element sibling = element.prev;
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.up

readonly XML.Node up

Description

Get the parent of the node, null if the current node is a Document.


					XML.Document doc = XML.loadFile("test.xml");
					XML.Element root = doc.root;
					XML.Element element = root.first;
					...
					XML.Element parent = element.up; // parent == root
			
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.value

readonly string value

Description

Returns the value of the node. The meaning of 'value' changes for the specific type.

  • Document: Empty
  • Element: Name of the element
  • Comment: The comment text
  • Unknown: The tag contents
  • Text: The text string
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.createComment()

XML.Comment createComment( string comment , int placement = XML.NodePlacement.Last , XML.Node afterThis = nullvar )

Parameters

comment The comment text.
placement Where the comment will be placed.
afterThis The child the new comment will be placed after.

Returns

XML.Comment An XML.Comment object.

Description

Create an XML.Comment child node.

This example code will place the comment "my comment" at the beginning of the file.

                XML.Document doc = XML.loadFile("test.xml");
                doc.createComment("my comment", XML.NodePlacement.First);
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.createDeclaration()

XML.Declaration createDeclaration( string declaration = 0 , int placement = XML.Placement.Last , XML.Node afterThis = nullvar )

Parameters

declaration Replace the default declaration with your own.
placement Where the declaration will be placed.
afterThis The child the new declaration will be placed after.

Returns

XML.Declaration An XML.Declaration object.

Description

Create an XML.Declaration child node.

This example code will create a new document and set the first child to be the default declaration. The default declaration is: xml version="1.0" encoding="UTF-8".

                XML.Document doc;
                doc.createDeclaration();
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.createElement()

XML.Element createElement( string name , int placement = XML.NodePlacement.Last , XML.Node afterThis = nullvar )

Parameters

name The name of the tag of the new element.
placement Where the element will be placed.
afterThis The child the new element will be placed after.

Returns

XML.Element An XML.Element object.

Description

Create an XML.Element child node.

This example code creates a blank document with a root element and subnode elements. The last line demonstrates how you might use the additional parameters.

                XML.Document doc;
                XML.Element root = doc.createElement("root");
                var element = root.createElement("firstChild");
                root.createElement("lastChild");
                root.createElement("middleChild", XML.NodePlacement.After, element);
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.createText()

XML.Text createText( string text , int placement = XML.NodePlacement.Last , XML.Node afterThis = nullvar )

Parameters

text The text string.
placement Where the text will be placed.
afterThis The child the new text will be placed after.

Returns

XML.Text An XML.Text object.

Description

Create an XML.Text child node.


                XML.Document doc;
                var students = doc.createElement("students");
                var student = root.createElement("student");
                child.attrs.name = "John Smith";
                var gradesNode = child.createElement("grades");
                
                Array classes = ["English", "Math", "Science", "Art"];
                Array grades = [52, 98, 97.3, 12];
                for (int i = 1; i <= classes.length; i++) {
                    var class = gradesNode.createElement(classes[i]);
                    class.createText(string.fromNum(grades[i]));
                }

                doc.saveAs("grades.xml");
            
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.createUnknown()

XML.Unknown createUnknown( string text , int placement = XML.NodePlacement.Last , XML.Node afterThis = nullvar )

Parameters

text The tag contents.
placement Where the unknown node will be placed.
afterThis The child the new unknown node will be placed after.

Returns

XML.Unknown An XML.Unknown object.

Description

Create an XML.Unknown child node.


				XML.Document doc;
				doc.createUnknown("testing this unknown thing 153");
				// results in the following tag
				// <!testing this unknown thing 153>
			
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.deleteChild()

deleteChild( XML.Node child )

Parameters

child The child node to be deleted.

Description

Delete a child from this node.

This example code deletes the first child from the root node of the document.

				XML.Document doc = XML.loadFile("test.xml");
				var root = doc.root;
				var first = root.first;
				root.deleteChild(first);
				doc.saveAs("test1.xml");
			
Do no remove, this fixes the anchor on doc.flexsim.com

XML.Node.deleteChildren()

deleteChildren( )

Description

Deletes all children from this node.

This example code deletes all the children from the root node of the document.

				XML.Document doc = XML.loadFile("test.xml");
				var root = doc.root;
				root.deleteChildren();
				doc.saveAs("test1.xml");